54 条题解
-
-1
#include <bits/stdc++.h> using namespace std; int main() { int n,x; cin>>n>>x; if(n==1 && x==1 or n==2 && x==2 or n==3 && x==3) { cout<<"tie"; } if(n==1 && x==2 or n==2 && x==3 or n==3 && x==1) { cout<<"win"; } if(n==1 && x==3 or n==2 && x==1 or n==3 && x==2) { cout<<"lose"; } return 0; }
-
-2
#include <bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; if(a1 && b2) { cout<<"win"; } else if(a1 && b3) { cout<<"lose"; } else if(a1 && b1) { cout<<"tie"; } else if(a2 && b1) { cout<<"lose"; } else if(a2 && b3) { cout<<"win"; } else if(a2 && b2) { cout<<"tie"; } else if(a3 && b2) { cout<<"lose"; } else if(a3 && b1) { cout<<"win"; } else if(a3 && b3) { cout<<"tie"; } return 0; }
-
-2
用a,b分别表示两个人,再列出可能出现的几种情况 #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; }
-
-2
#include <iostream> using namespace std; int main() { int a , b; cin >> a >> b; if(a==1 && b==2) { cout << "win"; } if(a==1 && b==3) { cout << "lose"; } if(a==2 && b==1) { cout << "lose"; } if(a==2 && b==3) { cout << "win"; } if(a==3 && b==1) { cout << "win"; } if(a==3 && b==2) { cout << "lose"; } else { cout << "tie"; } }
-
-2
#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; }**~~**~~**
-
-2
这估计是本题最短的AC代码了吧,来吧,不废话了,这一道题的话考的是分支问题(可以看标签)那我们就老老实实用 if - else if - else 来做,先列举出三种情况
a == b // ①两个值相等,平局,输出tie a == 1 && b == 2 || a == 2 && b == 3 || a == 3 && b == 1 // ②判断每个的克星,输出小T赢的情况 else cout << "lose"; // ③最后剩下的就是小K赢了
废话少说,上代码!
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a == b) cout << "tie"; else if (a == 1 && b == 2 || a == 2 && b == 3 || a == 3 && b == 1) cout << "win"; else cout << "lose"; return 0; }
-
-3
#include<bits/stdc++.h> //1代表石头 2代表剪刀 3代表布 using namespace std; int main(){ int a,b; a<=3; b<=3; cin>>a>>b; if(a==1&&b==2){ cout<<"win"; }if(a==2&&b==2){ cout<<"tie"; }if(a==3&&b==2){ cout<<"lose"; }if(a==1&&b==1){ cout<<"tie"; }if(a==2&&b==1){ cout<<"lose"; }if(a==3&&b==1){ cout<<"win"; }if(a==1&&b==3){ cout<<"lose"; }if(a==2&&b==3){ cout<<"win"; }if(a==3&&b==3){ cout<<"tie"; } return 0; }
信息
- ID
- 43
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 3
- 标签
- 递交数
- 3937
- 已通过
- 2031
- 上传者