65 条题解

  • 0
    @ 2023-8-11 16:37:04

    怪好玩的image

    • 0
      @ 2023-8-6 21:40:19

      LTC 这题的题号挺6啊 好了不废话了上代码🚀️ 来了个简单点的


      #include<iostream>
      using namespace std;//注释
      int main()
      {
      int n;
      string a[7]={"swim","rest","program","rest","read","math","rest"};
      cin>>n;
      cout<<a[n-1];
      return 0;
      }
      
      • 0
        @ 2023-8-6 21:14:57
        #include <bits/stdc++.h>
        using namespace std;
        
        int main() {
            int n;
            char a[7][5] = {
                "swim",
                "rest",
                "prog",
                "rest",
                "read",
                "math",
                "rest",
            };
            cin >> n;
            cout << (n-1)[a];
            if (n == 3) cout << "ram";
            return 0;
        }
        
        • 0
          @ 2023-8-4 11:35:50
          #include <iostream>
          using namespace std;
          int main()
          {
              int n;
              cin >> n;
              if (n == 1)
              {
                  cout << "swim" << endl;
              }
              else if (n == 3)
              {
                  cout << "program" << endl;
              }
              else if (n == 5)
              {
                  cout << "read" << endl;
              }
              else if (n == 6)
              {
                  cout << "math" << endl;
              }
              else
              {
                  cout << "rest" << endl;
              }
              return 0;
          }
          
          • 0
            @ 2023-7-31 9:08:21
            #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) //逝逝用else😕 
                {
                    cout << "rest";
                }
                return 0;
            }
            
            • 0
              @ 2023-7-25 20:50:42

              这道题如果所有的判断都是if那么当你输入1时,你会得到一个大大的swimrest,但如果我们在之后的3个if千加上else它就变成了else if这样这道题就对了代码如下:

              #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
                @ 2023-7-23 22:22:37
                #include <bits/stdc++.h>
                using namespace std;
                
                int main()
                {
                    int a;
                    cin >> a;
                    if(a == 1)//周一
                    {
                        cout << "swim";
                    }
                    else if(a == 3)//周三
                    {
                        cout << "program";
                    }
                    else if(a == 5)//周五
                    {
                        cout << "read";
                    }
                    else if(a == 6)//周六
                    {
                        cout << "math";
                    }
                    else//其它
                    {
                        cout << "rest";
                    }
                    return 0;
                }
                
                • 0
                  @ 2023-7-18 12:10:48
                  #include <iostream>
                  using namespace std;
                  int main()
                  {
                      int a;
                      cin>>a;
                      if (a==1)
                      {
                          cout<<"swim";
                      }
                      else if(a==3)
                      {
                          cout<<"program";
                      }
                      else if (a==5)
                      {
                          cout<<"read";
                      }
                      else if (a==6)
                      {
                          cout<<"math";
                      }
                      else
                      {
                          cout<<"rest";
                      }
                      return 0;
                  }
                  
                  • 0
                    @ 2023-6-4 13:29:06

                    全网最笨方法

                    //hetao29146用户
                    #include <iostream>
                    using namespace std;
                    int main()
                    {
                        int a;
                        cin>>a;
                        if (a==1) //判断是否是星期一
                            cout<<"swim"<<endl;
                        else
                            if (a==3)  //判断是否是星期三
                    			cout<<"program"<<endl;
                            else
                                if (a==5) //判断是否是星期五
                    				cout<<"read";
                                else 
                                    if (a==6) //判断是否是星期六
                    					cout<<"math";
                                    else 
                    					cout<<"rest";
                    }
                    
                    • 0
                      @ 2023-5-21 18:52:11
                      #include <iostream>
                      using namespace std;
                      
                      int main() {
                          int day;
                          cin >> day;
                      
                          switch (day) {//这个语句很高级,作用相当于if判断,可以省去if的麻烦
                              case 1:
                                  cout << "swim" << endl;
                                  break;
                              case 3:
                                  cout << "program" << endl;
                                  break;
                              case 5:
                                  cout << "read" << endl;
                                  break;
                              case 6:
                                  cout << "math" << endl;
                                  break;
                              default:
                                  cout << "rest" << endl;
                          }
                      
                          return 0;
                      }
                      
                      • 0
                        @ 2023-5-2 16:04:50
                            int n;
                            cin >> n;
                            bool a,b,c,d;//不懂了看我上一题的题解
                            a = (n == 1);
                            b = (n == 3);
                            c = (n == 5);
                            d = (n == 6);
                            if (a)//接下来判断
                            {
                                cout << "swim";
                            }
                            else if (b)//else if是“否则 如果(判断)”
                            {
                                cout << "program";
                            }
                            else if (c)
                            {
                                cout << "read";
                            }
                            else if (d)
                            {
                                cout << "math";
                            }
                            else
                            {
                                cout << "rest";
                            }
                        

                        </span>

                        这题也能用布尔!

                        点赞!!!image

                        (此代码来之不易,是原创,先点赞吧!)

                        • 0
                          @ 2023-4-30 15:04:52

                          OK呀,也是AC好吧。

                          #include <bits/stdc++.h>
                          using namespace std;
                          int main()
                          {
                              long long 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
                            @ 2023-3-28 21:50:19
                            #include<bits/stdc++.h>
                            using namespace std;
                            int main()
                            {
                                int x;
                                cin>>x;
                                if (x==1)
                                    cout<<"swim";
                                else if (x==3)
                                    cout<<"program";
                                else if (x==5)
                                    cout<<"read";
                                else if (x==6)
                                    cout<<"math";
                                else
                                    cout<<"rest";
                                return 0;
                            }
                            
                            • 0
                              @ 2023-2-6 14:57:12
                              #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
                                @ 2023-1-11 20:16:31
                                #include <iostream>
                                using namespace std;
                                int main()
                                {
                                    int n;
                                    cin>>n;
                                    if (n==1)
                                    {
                                        cout<<"swim";
                                    }
                                    else   #这里多套几次if--else也行
                                    {
                                        if(n==3)
                                        {
                                            cout<<"program";
                                        }
                                        else
                                        {
                                            if(n==5)
                                            {
                                                cout<<"read";
                                            }
                                            else
                                            {
                                                if(n==6)
                                                {
                                                    cout<<"math";
                                                }
                                                else
                                                {
                                                    cout<<"rest";
                                                }
                                            }
                                        }    
                                    }
                                    return 0;
                                }
                                
                                • 0
                                  @ 2023-1-11 20:14:50
                                  #include <iostream>
                                  using namespace std;
                                  int main()
                                  {
                                      int n;
                                      cin>>n;
                                      if (n==1)
                                      {
                                          cout<<"swim";
                                      }
                                      else#这里多套几次if——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-9-4 20:11:21

                                    这道题一如既往的简单,
                                    我的方法也简单粗暴。
                                    只要你不怕累,就可以定义一个string数组a,
                                    然后赋值......
                                    话不多说,上代码!

                                    #include<iostream>
                                    #include<string>
                                    using namespace std;
                                    string a[8];
                                    int main()
                                    {
                                        for (i = 1; i <= 7; i++)
                                        {
                                            a[i] = "rest";
                                        }
                                        a[1] = "swim";
                                        a[3] = "program";
                                        a[5] = "read";
                                        a[6] = "math";  //换成 a = {"e", "swim", "rest", "program", "rest", "read", "math", "rest"}也可以;
                                        int b;
                                        cin >> b;
                                        cout << a[b] << endl;
                                        re turn 0; 
                                    }
                                    

                                    小盆友们,您学会了吗?

                                    复制?
                                    代码不易,先点赞,再复制吧!
                                    (不要忘了删倒数第二行的空格!)

                                    • 0
                                      @ 2022-8-30 9:21:36

                                      #include <iostream> using namespace std; int main() { int n; cin >> n; if(n1) { cout<<"swim"; } if(n3) { cout<<"program"; } if(n5) { cout <<"read"; } if(n6) { cout<<"math"; } if(n2) { cout<<"rest"; } if(n4) { cout<<"rest"; } if(n==7) { cout <<"rest"; } return 0; } 先点赞再看!!!!!

                                      • 0
                                        @ 2022-8-29 14:01:22
                                        #include <bits/stdc++.h>//惯用万能头,万事皆从头。(笑) 
                                        using namespace std;
                                        int main()
                                        {
                                            long long n;//long long一在,谁都不爱;long long出征,寸草不生。
                                            cin >> n;
                                            if(n == 1)//用if,else if,else判断,来确定输出。
                                            {
                                                cout << "swim";
                                            }
                                            else if(n == 3) 
                                            {
                                                cout << "program";
                                            }
                                            else if(n == 5) 
                                            {
                                                cout << "read";
                                            }
                                            else if(n == 6)
                                            {
                                                cout << "math";
                                            }
                                            else//这里如果用else,不会出错,因为用的是if,else if,else;
                                            { 
                                                cout << "rest";
                                            }
                                            return 0;
                                        }
                                        
                                        
                                        • @ 2023-4-22 19:11:22

                                          我没有看懂为什么我用if就是错的啊

                                      • 0
                                        @ 2022-8-25 13:32:02

                                        谢谢大家的讲解

                                        信息

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