又一次将解题代码封装在函数里。
2023-12-24 21:06:08
发布于:广东
11阅读
0回复
0点赞
#include <iostream>
#include <cstring>
using namespace std;
void game(){
string s1[100], s2[100];
int n;
cin >> n;
for(int i = 0; i < n; i++){
cin >> s1[i] >> s2[i];
}
int sum = 0;
for(int i = 0; i < n; i++){
if((s1[i] == "Rock" and s2[i] == "Scissors") or (s1[i] == "Paper" and s2[i] == "Rock") or (s1[i] == "Scissors" and s2[i] == "Paper")){
cout << "Player1" << endl;
}else if((s2[i] == "Rock" and s1[i] == "Scissors") or (s2[i] == "Paper" and s1[i] == "Rock") or (s2[i] == "Scissors" and s1[i] == "Paper")){
cout << "Player2" << endl;
}else if(s1[i] == s2[i]){
cout << "Tie" << endl;
}
}
return ;
}
int main(){
game();
return 0;
}
这里空空如也
有帮助,赞一个