水题,注意下输出格式就好
#include <bits/stdc++.h>
using namespace std;
int min(int a,int b)
{
return a < b ? a : b;
}
int main()
{
int s[1005], g[1005], n;
int a[15], b[15], c[15];
int cnt = 1;
while (cin>>n && n)
{
memset(c, 0, sizeof (c));
for (int i=0; i<n; i++)
{
cin>>s[i];
c[s[i]]++;
}
cout<<"Game "<<cnt<<":"<<endl;
while (1)
{
memcpy(a, c, sizeof (c));
memset(b, 0, sizeof (b));
for (int i=0; i<n; i++)
{
cin>>g[i];
b[g[i]]++;
}
if (0 == g[0])
break;
int x = 0, y = 0;
for (int i=0; i<n; i++)
if (s[i] == g[i])
{
a[s[i]]--;
b[s[i]]--;
x++;
}
for (int i=1; i<=9; i++)
y += min(a[i], b[i]);
cout<<" ("<<x<<","<<y<<")"<<endl;
}
}
return 0;
}