超级水题,只要记下每行第一个代表国家的单词。。。然后计数排序输出。。(其他部分直接扔了。。。)
AC代码:
#include<cstdio>
#include<cstring>
int main () {
int flag = 0;
int A,B;
int n;
int num;
int top[1000],key[1000],temp[1000];
while (scanf( "%d", &n )) {
if (n == 0)
break;
memset ( top , 0 ,sizeof ( top ));
printf("Game %d:\n",++flag);
for (int i = 0 ; i < n ; i++) {
scanf( "%d" ,&top[i]);
}
num = 0;
while (1) {
memset ( key , 0 ,sizeof ( key ));
memset ( temp , 0 ,sizeof ( temp ));
for (int i = 0 ; i < n ;i++) {
scanf ("%d" ,&key[i]);
temp[i] = top[i];
if (key[i] == 0)
++num;
}
if (num == n )
break;
A = 0;
B = 0;
for (int i = 0; i < n; i++) {
if (key[i] == temp[i]) {
++A;
key[i] = 0;
temp[i] = 0;
}
}
for (int i = 0; i < n ; i++) {
if (key[i] != 0) {
for ( int j = 0; j < n ;j++) {
if (key[i] == temp[j]) {
++B;
key[i] = 0;
temp[j] = 0;
break;
}
}
}
}
printf(" (%d,%d)\n",A,B);
}
}
return 0;
}