UVa340 WA,是在想不出来是哪儿错了
地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=5&problem=276&mosmsg=Submission+received+with+ID+12339225
#include<iostream>
#include<cstring>
using namespace std;
const int maxsize=2000;
int main()
{
int a[maxsize],b[maxsize],flag_a[maxsize],flag_b[maxsize];
int game;
int n;
game=1;
while(cin>>n)
{
if(n==0)break;
int i;
cout<<"Game "<<game++<<":"<<endl;
for(i=0;i<n;++i)
cin>>a[i];
while(true)
{
for(i=0;i<n;++i)
cin>>b[i];
if(b[0]==0)break;
int A,B;
A=B=0;
memset(flag_a,0,maxsize);
memset(flag_b,0,maxsize);
int j;
for(i=0;i<n;++i)
{
if(a[i]==b[i])
{
++A;
flag_a[i]=flag_b[i]=1;
}
}
for(i=0;i<n;++i)
{
for(j=0;j<n;++j)
{
if(i!=j&&a[i]==b[j]&&flag_a[i]==0&&flag_b[j]==0)
{
flag_a[i]=1;
flag_b[j]=1;
++B;
}
}
}
cout<<" "<<"("<<A<<","<<B<<")"<<endl;
}
}
return 0;
}