#include <stdio.h>
#include <stdlib.h>
#include <process.h>
void main(void)
{
int answer[4],guess=0,a,b,times=0,i,j;
for(i=0;i<=3;i++)
{
randomize();
answer[i]=rand()%10;
for(j=0;j<i;j++)
{
while(answer[i]==answer[j])
{
answer[i]=rand()%10;
j=-1;
}
}
}
printf("please input four numbers e.g. 1234 and guess\n");
while(a!=4)
{
a=0;
b=0;
times++;
do
{
printf("%d ",times);
scanf("%d",&guess);
if(guess==0)
exit(0);
}while(guess>0||guess<9999);
for(i=3;i>-1;i--)
{
for(i=0;j<4;j++)
{
if((int)(guess/pow10(i))==answer[j])
{
if(i+j==3)
a=a+1;
else
b=b+1;
}
}
guess=guess-(int)(guess/pow10(i))*pow10(i);
}
printf("%dA%dB\n",a,b);
}
}