岂可修,居然做错一次,水题。
#include"iostream" using namespace std; int main() { int N; cin>>N; int A = 0, B = 0, C = 0;//A,B,C 表示甲的胜,平,负 int a[3]= {0},b[3]= {0}; char _a,_b,hashtable[3] = {‘B‘,‘C‘,‘J‘}; int k = N; while(k--) { cin>>_a>>_b; if((_a==‘B‘&&_b==‘B‘)||(_a==‘C‘&&_b==‘C‘)||(_a==‘J‘&&_b==‘J‘))//平局 B++; if(_a ==‘B‘&&_b==‘C‘) { A++; a[0]++; } else if(_a == ‘C‘ && _b == ‘J‘) { A++; a[1]++; } else if(_a == ‘J‘ && _b == ‘B‘) { A+=1; a[2]++; } else if(_b ==‘B‘&&_a==‘C‘) b[0]++; else if(_b == ‘C‘ && _a == ‘J‘) b[1]++; else if(_b == ‘J‘ && _a == ‘B‘) b[2]++; } printf("%d %d %d\n",A,B,N-A-B); printf("%d %d %d\n",N-A-B,B,A); int max = -1,k1,k2; for(int i = 0; i < 3; ++i) if(max < a[i]) { max = a[i]; k1 = i; } max = -1; for(int i = 0; i < 3; ++i) if(max < b[i]) { max = b[i]; k2 = i; } printf("%c %c",hashtable[k1],hashtable[k2]); return 0; }