7 条题解

  • 3
    @ 2024-2-7 15:54:06

    已AC,请放心食用

    这一道题非常简单,有三种解法

    我们可以选择朴实无华的直接判断偶数的算法(学到LV1以上的要是不会,我击毙你!

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        if (n % 2 == 0)
        {
            cout << "yes";
        }
        return 0;
    }
    

    我们也可以把"int main()"当成有返回值的函数来使用(直接在括号里定义变量,你别说,这样子竟然还不会出错

    #include <bits/stdc++.h>
    using namespace std;
    int main(int n)
    {
        int n;
        cin >> n;
        if (n % 2 == 0)
        {
            cout << "yes";
        }
        return 0;
    }
    

    我们甚至还可以用上有返回值的函数(但这当然没必要,属于是小题大做了)

    #include <iostream>
    using namespace std;
    int oushu(int n)
    {
        if (n % 2 == 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    int main()
    {
        int n;
        cin >> n;
        if (oushu(n))
        {
            cout << "yes";
        }
        return 0;
    }
    

    注意事项:如果是Level1的新手,可以看第一种朴实无华的解法,因为我的其他方法对于新手来讲,确实太高深了~

    养成好习惯,看后点个赞😎!

    一起点赞吧

    • 2
      @ 2022-12-25 10:13:21

      easy peasy

      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          int a;
          cin >> a;
          if (a % 2 == 0)
          {
              cout << "yes";
          }
          return 0;
      }
      
      • 1
        @ 2023-9-22 18:28:14
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
            int c;
            cin >> c;
            if(c % 2 == 0)
            {
                cout << "yes";
            }
            return 0;
        }//A
        
        • 0
          @ 2023-10-12 23:56:45
          #include<bits/stdc++.h>
          using namespace std;
          int main()
          {
              int n;
              cin>>n;
              if(n%2==0)
              {
                  cout<<"yes";
              }
              return 0;
          }
          
          • 0
            @ 2023-9-2 14:57:27

            太简单了

            #include <bits/stdc++.h>
            using namespace std;
            int main()
            {
                int n;
                cin>>n;
                if(n%2==0) cout<<"yes";//判断偶数,是就输出yes,否则不输出
                return 0;//结束整个代码
            }
            
            • 0
              @ 2023-4-5 17:36:22
              #include<bits/stdc++.h>
              using namespace std;
              int main()
              {
                  int x;
                  cin>>x;
                  if (x%2==0)
                      cout<<"yes";
                  return 0;
              }
              • 0
                @ 2023-1-15 11:13:34
                #include <iostream>//hetao3097453
                using namespace std;
                int main()
                {
                    int a;
                    cin >> a;
                    if(a % 2 == 0)
                    {
                        cout << "yes";
                    }
                    return 0;
                }
                
                
                • 1

                信息

                ID
                637
                时间
                1000ms
                内存
                16MiB
                难度
                1
                标签
                递交数
                136
                已通过
                97
                上传者