54 条题解

  • -3
    @ 2023-8-23 11:20:50
    #include <iostream>
    using namespace std;
    int main()
    {
        int t, k;  
        cin >> t >> k;
        if ((t == 1 && k == 2) || (t == 2 && k == 3) || (t == 3 && k == 1))
            cout << "win";
        else if (t == k)
            cout << "tie";
        else
            cout << "lose";
        return 0;
    }
    

    点个赞吧 !已AC✔ 可复制

    • -3
      @ 2023-8-23 8:29:21
      #include <iostream>
      using namespace std;
      int main()
      {
          int a,b;
          cin>>a>>b;//输入
          if ((a==1)&&(b==2)||(a==2)&&(b==3)||(a==3)&&b==1)//判断小T胜的情况
          {
              cout<<"win";//输出
          }
          else if (a==b)//判断平局的情况
          {
              cout<<"tie";//输出
          }
          else//判断小T败的情况
          {
              cout<<"lose";//输出
          }
          return 0;
      }
      

      编程不易😕 ,赞在哪里👀️ ?

    • -3
      @ 2023-8-16 20:24:02
      #include <iostream>
      using namespace std;
      int main()
      {
         int t,k;
         cin >> t >> k;
         if((t==1 && k==2) || (t==2 && k==3) || (t==3 && k==1))
         {
            cout << "win";//分三种胜利情况
         }
         else if(t==k)
         {
            cout << "tie";//相同时输出平局
         }
         else
         {
            cout << "lose";//其他情况输出输
         }
         return 0;
      }
      
      
      • -3
        @ 2023-8-14 14:48:52

        且看我暴走if

        #include <iostream>
        using namespace std;
        int main()
        {
            int t, k;
            cin >> t >> k;
            if (t == 1)
            {
                if (k == 1)
                {
                    cout << "tie";
                }
                else if (k == 2)
                {
                    cout << "win";
                }
                else
                {
                    cout << "lose";
                }
            }
            else if (t == 2)
            {
                if (k == 1)
                {
                    cout << "lose";
                }
                else if (k == 2)
                {
                    cout << "tie";
                }
                else
                {
                    cout << "win";
                }
            }
            else
            {
                if (k == 1)
                {
                    cout << "win";
                }
                else if (k == 2)
                {
                    cout << "lose";
                }
                else
                {
                    cout << "tie";
                }
            }
            return 0;
        }
        
        • @ 2023-8-23 11:22:48

          真狗!没你这么长的,也没你这么蠢的!

        • @ 2023-8-28 18:22:00

          @ 我也觉得......

      • -3
        @ 2023-8-3 21:54:00

        最简代码

        #include <iostream>
        using namespace std;
        int main()
        {
            int a,b;
            cin>>a>>b;
            if (a==b) cout<<"tie";
            else if (b-a==1 || a-b==2) cout<<"win";
            else cout<<"lose";
            return 0;
        }
        
        • @ 2023-8-30 13:09:39
          //挑战全网最简代码,不信你就试试看
          #include <iostream>
          using namespace std;
          int main()
          {
              cout << "lose";
              return 0;
          }
          
        • @ 2023-8-30 13:10:22

          有我简单吗?!👎 👎 👎

      • -3
        @ 2023-8-3 17:04:15

        不会就我写的很长吧👀️ 题解来喽

        #include<iostream>
        using namespace std;
        int main()
        {
            int T , K;
            cin >> T >> K;
            for (int i = 1;i <= 1;i++)//这里我用了一次循环哈(我闲的👀️ )
            {
                if (T == K)
                {
                    cout << "tie";
                    break;//跳出循环,不需要再判断了
                } 
                if (T == 1)//下面都是判断了
                {
                     if(K == 2)
                     {
                        cout << "win";
                     }
                     else
                     {
                        cout << "lose";
                     }
                }
                else if (T == 2)
                {
                    if (K == 1)
                    {
                        cout << "lose";
                    }
                    else{
                        cout << "win";
                    }
                }
                else
                {
                    if(K == 1)
                    {
                        cout << "win";
                    }
                    else
                    {
                        cout << "lose";
                    }
                }
            }
            return 0;
        }
        
        • -3
          @ 2023-7-10 20:50:51

          #include <bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; if(a == 1 && b == 2) { cout<<"win"; } else if(a == 1 && b == 3) { cout<<"lose"; } else if(a == 2 && b == 1) { cout<<"lose"; } else if(a == 2 && b == 3) { cout<<"win"; } else if(a == 3 && b == 1) { cout<<"win"; } else if(a == 3 && b == 2) { cout<<"lose"; } else { cout<<"tie"; } return 0; }🚀️ 小盆友放心食用, 已AC.

          • -3
            @ 2023-7-10 20:48:07

            #include <bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; if(a == 1 && b == 2) { cout<<"win"; } else if(a == 1 && b == 3) { cout<<"lose"; } else if(a == 2 && b == 1) { cout<<"lose"; } else if(a == 2 && b == 3) { cout<<"win"; } else if(a == 3 && b == 1) { cout<<"win"; } else if(a == 3 && b == 2) { cout<<"lose"; } else { cout<<"tie"; } return 0; }

            • -3
              @ 2023-7-10 16:28:05

              可以用int类型的计算来判断结果,这样就变成了5种结果,再用表示或的“||”符只需用几个if了(

              #include <bits/stdc++.h> 
              using namespace std;
              int main()
              {
                  int a,b;cin>>a>>b;
                  if((b-a==1)||(b-a==-2))//当差为正1(1,2和2,3的结果)和负2时(1,3的结果)就赢
              
                  {
                      cout<<"win";
                  }
                  else if((b-a==2)||(b-a==-1))//当差为正2(3,1的结果)和负1时(2,1和3,2的结果)就输
                  {
                      cout<<"lose";
                  }
                  else
                  {
                      cout<<"tie";
                  }
                  return 0;
              }
              

              算式为b-a,不用负数也可以把算式搞成a-b,你也可以用绝对值(被打)

              • -3

                这道题只要分类枚举,判断所有情况即可。核心代码:

                #include <iostream>
                using namespace std;
                int main()
                {
                	int a,b;
                	cin >> a >> b;
                	if (a == b)
                	{
                		cout << "tie";
                	}
                	else if (a == 1)
                	{
                		if (b == 2)
                		{
                			cout << "win";
                		}
                		else if (b == 3)
                		{
                			cout << "lose";
                		}
                	}
                	else if (a == 2)
                	{
                		if (b == 3)
                		{
                			cout << "win";
                		}
                		else if (b == 1)
                		{
                			cout << "lose";
                		}
                	}
                	else if (a == 3)
                	{
                		if (b == 1)
                		{
                			cout << "win";
                		}
                		else if (b == 2)
                		{
                			cout << "lose";
                		}
                	}
                	return 0;
                }
                
                • -3
                  @ 2022-6-1 13:57:46

                  题目看着很长,实际就是a,b=(1,2,3)。每个人都有3种情况,一共9种出拳组合,利用if-else if-else 写清楚这个关系即可。

                  if (a == b)
                  {
                  	cout << "tie";
                  }
                  else if (a == 1)
                  {
                  	if (b == 2)
                  	{
                  		cout << "win";
                  	}
                  	else if (b == 3)
                  	{
                  		cout << "lose";
                  	}
                  }
                  else if (a == 2)
                  {
                  	if (b == 3)
                  	{
                  		cout << "win";
                  	}
                  	else if (b == 1)
                  	{
                  		cout << "lose";
                  	}
                  }
                  else if (a == 3)
                  {
                  	if (b == 1)
                  	{
                  		cout << "win";
                  	}
                  	else if (b == 2)
                  	{
                  		cout << "lose";
                  	}
                  }
                  
                  • @ 2022-8-24 21:34:18

                    #include <bits/stdc++.h> using namespace std; int main() { int at,bk; cin >> at >> bk; if (at == 1 && bk == 2) { cout << "win"; return 0; } else if (at == 1 && bk == 1) { cout << "tie"; return 0; } else { cout << "lose"; return 0; } if (at == 2 && bk == 2) { cout << "tie"; return 0; } else if (at == 2 && bk == 1) { cout << "lose"; return 0; } else { cout << "win"; return 0; } if (at == 3 && bk == 1) { cout << "win"; return 0; } else if (at == 3 && bk == 3) { cout << "tie"; return 0; } else { cout << "lose"; return 0; } return 0; }

                    对对对

                • -5
                  @ 2022-6-3 15:51:29

                  这题目很简单,只要用if...else if...else if...就可以完成了。 核心代码:

                  if(a==b)cout<<"tie";
                  else if(a==1)
                  {
                  	if(b==2)cout<<"win";
                  	else cout<<"lose";
                  }
                  else if(a==2)
                  {
                  	if(b==1)cout<<"lose";
                  	else cout<<"win";
                  }
                  else if(a==3)
                  {
                  	if(b==1)cout<<"win";
                  	else cout<<"lose";
                  }
                  
                  • -5
                    @ 2022-5-22 20:58:37

                    这道题的思路很简单(1石头,2剪刀,3布)

                    只要明白数字①小于数字②,说明数字①赢(特殊情况除外,数字①是3,数字②是1)

                    	if((t==3 && k==1) || t<k) cout<<"win";
                    	else if(t==k) cout<<"tie";
                    	else cout<<"lose";
                    
                    • -7
                      @ 2022-7-11 19:17:25

                      switch快速求解

                      switch (a){
                          case 1;{switch (b){
                              case 1:cout << 'tie' << endl >>;break
                              ...
                              ...
                          }};break;
                          ...
                          ...//此处...为省略代码
                      }
                      

                      信息

                      ID
                      43
                      时间
                      1000ms
                      内存
                      16MiB
                      难度
                      3
                      标签
                      递交数
                      3937
                      已通过
                      2031
                      上传者