65 条题解

  • 0
    @ 2022-8-22 22:01:51

    嘻嘻,简洁的代码来喽!!

    image

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int n;
        cin >> n;
        if(n == 1) cout << "swim";
        else if(n == 3) cout << "program";
        else if(n == 5) cout << "read";
        else if(n == 6) cout << "math";
        else cout << "rest";
        return 0;
    }
    
    • 0
      @ 2022-8-22 16:09:53

      暴 力 解 法``

      #include<iostream>
      using namespace std;
      int main()
      {
          int a;
          cin>>a;
          if (a==3)
              cout<<"program";
          if (a==1)
              cout<<"swim";
          if (a==5)
              cout<<"read";
          if (a==6)
              cout<<"math";
          if (a==2)
              cout<<"rest";
          if (a==4)
              cout<<"rest";
          if (a==7)
              cout<<"rest";
          
          return 0;
      } 
      
      • @ 2022-8-22 22:03:00
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
            int n;
            cin >> n;
            if(n == 1) cout << "swim";
            else if(n == 3) cout << "program";
            else if(n == 5) cout << "read";
            else if(n == 6) cout << "math";
            else cout << "rest";
            return 0;
        }
        
      • @ 2023-8-9 19:42:04
        #include <iostream>
        using namespace std;
        int main()
        {
            int a;
            string b[7]={"swim","rest","program","rest","read","math","rest"};
            cin>>a;
            cout<<b[a-1];
        }
        
    • 0
      @ 2022-8-21 17:34:36

      简单的题目,疯狂判断就可以

      if(n==1)
          cout<<"swim";
      if(n==3)
          cout<<"program";
      if(n==5)
          cout<<"read";
      if(n==6)
          cout<<"math";
      if(n==2||n==4||n==7)
          cout<<"rest";
      

      当然,最后一个判断也可以写成

      if(n!=1&&n!=3&&n!=5%%n!=6)
          cout<<"rest";
      

      不过就是更麻烦些而已

      • @ 2022-8-21 17:35:12

        完整代码

        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
            int n;
            cin >> n;
            if(n==1)
                cout<<"swim";
            if(n==3)
                cout<<"program";
            if(n==5)
                cout<<"read";
            if(n==6)
                cout<<"math";
            if(n==2||n==4||n==7)
                cout<<"rest";
            return 0;
        }
        
      • @ 2022-8-22 22:02:38
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
            int n;
            cin >> n;
            if(n == 1) cout << "swim";
            else if(n == 3) cout << "program";
            else if(n == 5) cout << "read";
            else if(n == 6) cout << "math";
            else cout << "rest";
            return 0;
        }
        
    • 0
      @ 2022-8-17 18:45:09
      #include <bits/stdc++.h> 
      using namespace std;
      int main()
      {
          int n;
          cin >> n;
          if(n == 1)//进行4次判断,来确定输出。
          {
              cout << "swim";
          }
        
          if(n == 5) 
          {
              cout << "read";
          }
          if(n == 3) 
          {
              cout << "program";
          }
          if(n == 6)
          {
              cout << "math";
          }
          if(n == 2 or n == 4 or n == 7)//这里如果用else,会出错,因为会把rest追加到program和read末尾。
          { 
              cout << "rest";
          }
          return 0;
      }
      
      • 0
        @ 2022-8-16 10:29:57

        能用万能开头吗 #include <iostream>

        • 0
          @ 2022-8-10 21:05:33

          #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if(n == 1)//判断各个项目,并输出指定词语 { cout << "swim"; } if(n == 3) { cout << "program"; } if(n == 5) { cout << "read"; } if(n == 6) { cout << "math"; } if(n == 2 or n == 4 or n == 7) { cout << "rest"; } return 0; }

          • 0
            @ 2022-8-3 12:55:53

            简单判断而已

            #include <bits/stdc++.h>
            using namespace std;
            int main()
            {
            int n;
            cin >> n;
            if (n == 1)
            {
            cout << "swim";
            }
            else if (n == 3)
            {
            cout << "program";
            }
            else if (n == 5)
            {
            cout << "read";
            }
            else if (n == 6)
            {
            cout << "math";
            }
            else
            {
            cout << "rest";
            }
            return 0;
            }
            
            • 0
              @ 2022-8-2 19:34:44
              #include <iostream> 
              using namespace std;
              int main()
              {
                  int n;
                  cin >> n;
                  if(n == 1)
                  {
                      cout << "swim";
                  }
                  if(n == 3) 
                  {
                      cout << "program";
                  }
                  if(n == 5) 
                  {
                      cout << "read";
                  }
                  if(n == 6)
                  {
                      cout << "math";
                  }
                  if(n == 2 or n == 4 or n == 7)
                  { 
                      cout << "rest";
                  }
                  return 0;
              }
              
              • 0
                @ 2022-7-20 11:29:43

                傻瓜式做法:

                #include <iostream>
                using namespace std;
                int main()
                {
                    int n;
                    cin >> n;
                    if (n == 1)
                    {
                        cout << "swim";
                    }   
                    if (n == 3)
                    {
                        cout << "program";
                    }
                    if (n == 5)
                    {
                        cout << "read";
                    }
                    if (n == 6)
                    {
                        cout << "math";
                    }
                    if (n == 2 or n == 4 or n == 7)
                    {
                        cout << "rest";
                    }
                    return 0;
                }
                

                正确做法

                #include <iostream>
                using namespace std;
                int main()
                {
                    cout << "I don't know!"
                    return 0;
                }
                
                • 0
                  @ 2022-7-9 15:51:33
                  //这道题的话输入是一个整数,还有多种判断条件,所以建议使用switch语句
                  //代码: cin >> i;
                  switch(i){
                      case 1:cout << "swim";break;//break是要有点如果没有,switch默认后面全部成立
                      .../省略的代码
                      ...
                      ...
                      default:...;break;/default表示以上全部case全部没有匹配成功的情况,一般放在最后面 } 
                  
                  </span>
                  • 0
                    @ 2022-7-9 15:49:08

                    //这道题的话输入是一个整数,还有多种判断条件,所以建议使用switch语句 //代码: cin >> i switch(i){ case 1:cout << "swim";break;//break是要有点如果没有,switch默认后面全部成立 .../省略的代码 ... ... default:...;break;/default表示以上全部case全部没有匹配成功的情况,一般放在最后面 } </span>

                    • 0
                      @ 2022-7-8 15:57:47

                      这题比较简单,但有一个地方需要注意,不能用if语句判断1356四天后直接在6后加else语句,否则135三天会输出两个单词。

                      • 0
                        @ 2022-7-5 22:57:03
                            if(n == 1)
                            {
                                cout << "swim";
                            }
                            if(n == 2)
                            {
                                cout << "rest";
                            }
                            if(n == 3)
                            {
                                cout << "program";
                            }
                            if(n == 4)
                            {
                                cout << "rest";
                            }
                            if(n == 5)
                            {
                                cout << "read";
                            }
                            if(n == 6)
                            {
                                cout << "math";
                            }
                            if(n == 7)
                            {
                                cout << "rest";
                            }
                            超级简单
                        
                        • 0
                          @ 2022-7-3 21:45:58

                          #include <iostream> using namespace std; int main() { int a; cin >> a; if (a == 1) { cout << "swim"; } if (a == 3) { cout << "program"; } if (a == 5) { cout << "read"; } if (a == 6) { cout << "math"; } else { cout << "rest"; } return 0; }

                          • 0
                            @ 2022-6-4 17:51:19

                            #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; if(n1) { cout<<"swim"; } else if(n3) { cout<<"program"; } else if(n5) { cout<<"read"; } else if(n6) { cout<<"math"; } else { cout<<"rest"; } }

                            • 0
                              @ 2022-5-26 14:48:35

                              题解:就是多个if条件判断,注意用一个if-else输出没有课程的内容,输出rest。 也可以使用if-else if-else。

                              • -1
                                @ 2023-8-29 18:47:22

                                //以下为判断部分

                                注:有错误发邮件告诉我 ——邮箱:liuhaoxuan_0820@hotmail.com

                                1. int n; cin>>n; if (n1) { cout<<"swim"; } if (n3) { cout<<"program"; } if (n5) { cout<<"read"; } if (n6) { cout<<"math"; } if (n2 or n4 or n==7) { cout<<"rest"; }
                                • -1
                                  @ 2023-8-26 17:52:30

                                  #include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) { cout << "swim"; } else { if (n == 3) { cout << "program"; } else { if (n == 5) { cout << "read"; } else { if (n == 6) { cout << "math"; } else { cout << "rest"; } } } } return 0; }

                                  • -1
                                    @ 2023-8-17 10:32:10

                                    这题很简单,用4次if就OK

                                    if(n == 1)
                                    {
                                    cout << "swim";
                                    }
                                    if(n == 3)
                                    {
                                    cout << "program";
                                    }
                                    if(n == 5)
                                    {
                                    cout << "read";
                                    }
                                    if(n == 6)
                                    {
                                    cout << "math";
                                    }
                                    if(n == 2 or n == 4 or n == 7)
                                    {
                                    cout << "rest";
                                    }
                                    return 0;
                                    
                                    给个赞吧
                                    
                                    • -1
                                      @ 2023-8-15 9:40:29

                                      ga

                                      信息

                                      ID
                                      666
                                      时间
                                      1000ms
                                      内存
                                      64MiB
                                      难度
                                      4
                                      标签
                                      递交数
                                      8405
                                      已通过
                                      3903
                                      上传者