题目链接:http://exam.upc.edu.cn/problem.php?cid=1372&pid=11
题意:ABC三人打牌,他们只能出第一张牌,牌的内容说明下一回合是谁出牌。最后的人赢。
这个就是模拟,利用queue来模拟
#include<bits/stdc++.h>
using namespace std;
char s[4][1000];
int main()
{
for(int i=0;i<3;i++){
scanf("%s",s[i]);
}
queue<char>q[3];
for(int i=0;i<3;i++){
for(int j=0;j<strlen(s[i]);j++){
q[i].push(s[i][j]);
}
}
char tmp='a',t='a';
while(1){
//cout<<tmp<<endl;
t=tmp;
tmp=q[tmp-'a'].front();
q[t-'a'].pop();
if(q[tmp-'a'].empty()){
printf("%c\n",tmp-32);
break;
}
}
return 0;
}