12 条题解

  • 3
    @ 2022-12-11 16:19:31
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int x;
        cin >> x;
        if (x % 2 == 0 || x % 3 == 0)
        {
            cout << "Y";
        }
        else
        {
            cout << "N";
        }
        return 0;
    }
    

    我想不需要解释了吧!

    • 3
      @ 2022-7-4 21:55:38
      #include <iostream>
      using namespace std;
      int main()
      {
          int n;
          cin >> n;
          if (n % 2 == 0)//判断n是否为2的倍数
          {
              cout << "Y";
          }
          else if (n % 3 == 0)//判断n是否为3的倍数
          {
              cout << "Y";
          }
          else
          {
              cout << "N";
          }
          return 0;
      }
      
      • 2
        @ 2022-7-20 11:23:33

        简单程度:easy

        #include <iostream>
        using namespace std;
        int main()
        {
            int n;
            cin >> n;
            if (n % 2 == 0 or n % 3 == 0)
            {
                cout << "Y";
            }   
            else
            {
                cout << "N";
            }
            return 0;
        }
        
        • 1
          @ 2024-4-29 20:29:52
          #include <bits/stdc++.h>
          using namespace std;
          int main()
          {
              int n;
              cin>>n;
              if(n%2==0||n%3==0)
              {
                  cout<<"Y";
              }
              else
              {
                  cout<<"N";
              }
              return 0;
          }//AC
          
          • 1
            @ 2022-7-13 22:39:40

            这题就不写注释了,写就是照搬题目了😕

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

            编码不易😕,点赞走起👀️
            记得点赞再抱走奥😄

            • 1
              @ 2022-7-7 13:18:13

              最优解法:

              #include <iostream> 
              using namespace std; 
              int main() 
              { 
                  int a; 
                  cin >> a; 
                  if (a % 2 == 0 || a % 3 == 0)
                  { 
                      cout << "Y";
                  } 
                  else 
                  { 
                      cout << "N"; 
                  } 
                  return 0; 
              }
              

              ||代表或

              • 0
                @ 2023-4-6 22:13:23
                #include<bits/stdc++.h>
                using namespace std;
                int main()
                {
                    int x;
                    cin>>x;
                    if (x%2==0||x%3==0)
                        cout<<"Y";
                    else
                        cout<<"N";
                    return 0;
                }
                • 0
                  @ 2022-7-24 23:09:28
                  #include <bits/stdc++.h> 
                  using namespace std;
                  int main()
                  {
                      int n;
                      cin >> n;
                      if(n%2==0||n%3==0)//判断其是否为2的倍数或者为3的倍数
                      {
                          cout << "Y";
                      }
                      else
                      {
                          cout << "N";
                      }
                      return 0;
                  }
                  简简单单
                  
                  • 0
                    @ 2022-7-11 11:30:09
                    #include <iostream>//调用
                    using namespace std;
                    int a; 
                    int main(){
                    	cin >> a;//输入a
                    	cout << ((a % 2 == 0 or a % 3 == 0)?'Y':'N');//三目运算符,省行数。
                        //如不加外括号程序会先运行cout而不是三目运算符
                    	return 0 ;
                    }
                    
                    • -1
                      @ 2022-6-4 17:41:47

                      #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; if(n%20 or n%30) { cout<<"Y"; } else { cout<<"N"; } }

                      • -2
                        @ 2022-7-8 16:05:58

                        此题主要考察%和“或者”,%表示求余,“或者”比较基础的代码可以写成两个if else嵌套的形式。

                        #include <iostream>
                        using namespace std;
                        int main()
                        {
                            int n;
                            cin >>n;
                            if (n%2==0)
                            {
                                cout <<"Y";
                            }
                            else
                            {
                                if (n%3==0)
                                {
                                    cout <<"Y";
                                }
                                else
                                {
                                    cout <<"N";
                                }
                            }
                        }
                        
                        • @ 2022-12-11 16:20:50

                          你这有点儿麻烦, 改一下吧。

                      • -3
                        @ 2022-5-26 14:54:48

                        题解:是2的倍数或者是3的倍数,可以使用逻辑语句“或”。 如果使用两个if语句,需要考虑,6这个数字,有可能会输出两个Y。

                        • 1

                        信息

                        ID
                        670
                        时间
                        1000ms
                        内存
                        16MiB
                        难度
                        2
                        标签
                        递交数
                        455
                        已通过
                        287
                        上传者