int date[4];
int comp(int a,int b,int c,int d)
{
int i,sum=0;
for(i=0;i<4;i++)
{
if(date[i]==a)
sum++;
if(date[i]==b)
sum++;
if(date[i]==c)
sum++;
if(date[i]==d)
sum++;
}
cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl<<sum<<endl;
return sum;
}
int main()
{
int i;
int guess[10];
int num[10];
int total=0;
for(i=0;i<4;i++)
cin>>date[i];
for(i=0;i<10;i++)
num[i]=0;
for(i=0;i<10;i++)
guess[i]=i;
if(comp(guess[0],guess[1],guess[2],guess[3])==0)
{
num[0]=-1;
num[1]=-1;
num[2]=-1;
num[3]=-1;
if(comp(guess[0],guess[1],guess[2],guess[4])==0)
{
num[4]=-1;
}
else
{
num[4]=1;
total++;
}
}
else if(comp(guess[0],guess[1],guess[2],guess[3])==4)
{
num[0]=1;
num[1]=1;
num[2]=1;
num[3]=1;
total+=4;
return 0;
}
else
{
if(
comp(guess[4],guess[1],guess[2],guess[3])
+comp(guess[0],guess[4],guess[2],guess[3])
+comp(guess[0],guess[1],guess[4],guess[3])
+comp(guess[0],guess[1],guess[2],guess[4])
>
4*comp(guess[0],guess[1],guess[2],guess[3])
)
{
num[4]=1;
total+=1;
if(
comp(guess[0],guess[1],guess[2],guess[3])
==
comp(guess[4],guess[1],guess[2],guess[3])
)
{
num[0]=1;
total++;
}
else
num[0]=-1;
if(
comp(guess[0],guess[1],guess[2],guess[3])
==
comp(guess[0],guess[4],guess[2],guess[3])
)
{
num[1]=1;
total++;
}
else
num[1]=-1;
if(
comp(guess[0],guess[1],guess[2],guess[3])
==
comp(guess[0],guess[1],guess[4],guess[3])
)
{
num[2]=1;
total++;
}
else
num[2]=-1;
if(
comp(guess[0],guess[1],guess[2],guess[3])
==
comp(guess[0],guess[1],guess[2],guess[4])
)
{
num[3]=1;
total++;
}
else
num[3]=-1;
}
else
{
num[4]=-1;
if(
comp(guess[0],guess[1],guess[2],guess[3])
>
comp(guess[4],guess[1],guess[2],guess[3])
)
{
num[0]=1;
total++;
}
else
num[0]=-1;
if(
comp(guess[0],guess[1],guess[2],guess[3])
>
comp(guess[0],guess[4],guess[2],guess[3])
)
{
num[1]=1;
total++;
}
else
num[1]=-1;
if(
comp(guess[0],guess[1],guess[2],guess[3])
>
comp(guess[0],guess[1],guess[4],guess[3])
)
{
num[2]=1;
total++;
}
else
num[2]=-1;
if(
comp(guess[0],guess[1],guess[2],guess[3])
>
comp(guess[0],guess[1],guess[2],guess[4])
)
{
num[3]=1;
total++;
}
else
num[3]=-1;
}
}
//cout<<total<<"~~~~"<<endl;
if(comp(guess[5],guess[6],guess[7],guess[8])==0)
{
num[5]=-1;
num[6]=-1;
num[7]=-1;
num[8]=-1;
if(comp(guess[5],guess[6],guess[7],guess[8])==0)
{
num[9]=-1;
}
else
{
num[9]=1;
total++;
}
}
else if(comp(guess[5],guess[6],guess[7],guess[8])==4)
{
num[5]=1;
num[6]=1;
num[7]=1;
num[8]=1;
total+=4;
return 0;
}
else
{
if(
comp(guess[9],guess[6],guess[7],guess[8])
+comp(guess[5],guess[9],guess[7],guess[8])
+comp(guess[5],guess[6],guess[9],guess[8])
+comp(guess[5],guess[6],guess[7],guess[9])
>
4*comp(guess[5],guess[6],guess[7],guess[8])
)
{
num[9]=1;
total+=1;
if(
comp(guess[5],guess[6],guess[7],guess[8])
==
comp(guess[9],guess[6],guess[7],guess[8])
)
{
num[5]=1;
total++;
}
else
num[5]=-1;
if(
comp(guess[5],guess[6],guess[7],guess[8])
==
comp(guess[5],guess[9],guess[7],guess[8])
)
{
num[6]=1;
total++;
}
else
num[6]=-1;
if(
comp(guess[5],guess[6],guess[7],guess[8])
==
comp(guess[5],guess[6],guess[9],guess[8])
)
{
num[7]=1;
total++;
}
else
num[7]=-1;
if(
comp(guess[5],guess[6],guess[7],guess[8])
==
comp(guess[5],guess[6],guess[7],guess[9])
)
{
num[8]=1;
total++;
}
else
num[8]=-1;
}
else
{
num[9]=-1;
if(
comp(guess[5],guess[6],guess[7],guess[8])
>
comp(guess[9],guess[6],guess[7],guess[8])
)
{
num[5]=1;
total++;
}
else
num[5]=-1;
if(
comp(guess[5],guess[6],guess[7],guess[8])
>
comp(guess[5],guess[9],guess[7],guess[8])
)
{
num[6]=1;
total++;
}
else
num[6]=-1;
if(
comp(guess[5],guess[6],guess[7],guess[8])
>
comp(guess[5],guess[6],guess[9],guess[8])
)
{
num[7]=1;
total++;
}
else
num[7]=-1;
if(
comp(guess[5],guess[6],guess[7],guess[8])
>
comp(guess[5],guess[6],guess[7],guess[9])
)
{
num[8]=1;
total++;
}
else
num[8]=-1;
}
}
for(i=0;i<10;i++)
if(num[i]==1)
cout<<i<<" ";
}
评论