void checkarr (char check[Num])
{
int i=0,temp;
srand (time(0));
do
{WRONG:check=''''0''''+random(9);
temp=i;
if (i>0)
while ((temp--)>0)
if (check==check[temp] goto WRONG;
i++;
}
while (i<=3);
int i=0;
int n;
int acount,bcount;
int temp;
char YN;
WHILE:while(1) /* The game is looping */
{ clrscr();
printf ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
acount=bcount=0;
/* Initialize */
printf (" 第一次来吗?看看帮助? (Yes or No):");
if ((YN=getchar ())==''''Y''''||YN==''''y'''')
{ printf ("\n\b");
flushall ();
show_help();
scanf ("%*c);
flushall();
}
for (n=1;n<=TIMES;n++)
{
SORRY:printf ("四位不同数字,NO.%d(q 退出,n 重来):",n);
for (i=0;i<=NUM-1;i++)
{input =getchar();
if (input [0]==''''q''''||input [0]==''''Q'''')
{clrscr();
printf ("\n\n\n\n\n\n\n\n\n ******程序己退出,请关闭窗口*****\n\n\n\n\n");
exit(0);
}
if (iinput[0]==''''n''''||input[0]==''''N'''')
{printf ("重来一盘....\n\n");
goto WHILE;
}
}
i=0;
do /*check a char */
{ if (input<''''0''''||input>''''9'''')
{printf ("%c >>>>>>>>> 非法字符!\n\n",input);
flushall(); /* clear input stream! */
goto SORRY;
}
temp=i;
while ((temp++)<2)
if (input ==input[temp])
{printf ("%c >>>>>>>>> 相同数字!\n\n",input);
flushall();
goto SORRY;
}
for (temp=0;temp<=3;temp++)
{if (input==check[temp]&&i==temp)
acount++;
if (input==check[temp])
bcount++;
}
printf ("%c",input[i++]);
}while (i<=3);
if (acount==4)
{printf ("\n\n\n");
for (temp=0;temp<=3;temp++)
printf ("%c ",check[temp]);
if (n<=5)
{ printf ("做的好,你真优秀! \n\n再来一盘?(Yes or No):");
if(((YN=getchar()==''''N'''')||((YN==getchar())==''''n'''');
{clrscr();
printf ("\n\n\n\n\n\n\n\n\n ******程序己退出,请关闭窗口*****\n\n\n\n\n");
exit(0);}
break; /* end of for loop */
}
else
if (n>5&&n<=10)
{printf ("你赢了! \n\n再来一盘?(Yes or No):");
if(((YN=getchar()==''''N'''')||((YN==getchar())==''''n'''');
{clrscr();
printf ("\n\n\n\n\n\n\n\n\n ******程序己退出,请关闭窗口*****\n\n\n\n\n");
exit(0);}
break; /* end of for loop */
}
if (n>10)
{printf ("给出的数字为:");
for (temp=0;temp<=3;temp++) printf ("%c",check[temp]);
printf (" 别灰心。 \n\n再来一盘?(Yes or No):");
if(((YN=getchar()==''''N'''')||((YN==getchar())==''''n'''');
{clrscr();
printf ("\n\n\n\n\n\n\n\n\n ******程序己退出,请关闭窗口*****\n\n\n\n\n");
exit(0);}
flushall();
} /* end of while loop. */
} /* end of main(). */