解题思路:用if语句逐一判断,用变量index记录是否该平局
#include<bits/stdc++.h>
using namespace std;
int main(){int n,index=0;;cin>>n;getchar();string s;while(cin>>s){if(s=="End")break;if(index==n){cout<<s<<endl;index=0;continue;}if(s=="Bu"){cout<<"JianDao"<<endl;index++;}if(s=="ChuiZi"){cout<<"Bu"<<endl;index++;}if(s=="JianDao"){cout<<"ChuiZi"<<endl;index++;}
}
}
运行结果(耗时太长不推荐这么写):