程序运行结果怎么不对啊?
#include "math.h"#include "stdlib.h"
main()
{
int guess,answer[4],i,j,proper,times=0;
randomize();
for(i=0;i<4;i++)
{
answer[i]=rand()%10;
for(j=0;j<i;j++)
if(answer[j]==answer[i]) { answer[i]=rand()%10; j=-1; }
}
for(i=0;i<4;i++)
printf("%d",answer[i]);
printf("\nPlease Guess:\n");
while(proper!=4)
{
proper=0;
printf("%d: ",++times);
scanf("%d",&guess);
while(guess<0 || guess>9999)
{
printf("Input error......\nPlease reenter guess:\n");
scanf("%d",&guess);
}
for(j=3;j>=0;j--)
{
for(i=0;i<4;i++)
if(answer[i]==(int)(guess/pow(10,j))) proper++;
guess=guess-(int)(guess/pow(10,j))*pow(10,j);
printf("%d\n",guess);
}
if(proper==4) printf("Very Good!!\nPress any key to quit..");
else printf(" %d correct\n",proper);
}
getch();
}