新手请教一个问题
#include<stdio.h> #include<math.h>
#include<stdlib.h>
#include<process.h>
void main(void)
{
int answer[4],guess,a,b,i,j,times=0;
puts("test");
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 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(j=0;j<4;j++)
{
if((int)(guess/pow(10,i))==answer[j])
{
if(i+j==3)
a+=1;
else
b+=1;
}
}
guess=guess-(int)(guess/pow(10,i))*pow(10,i);
}
printf("%dA%dB\n",a,b);
}
getch();
}
这段代码中j=-1是什么意思