帮忙找个错吧,找了老长时间了……(新手,刚入门,,)
程序代码:#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
#include <time.h>
#include <stdlib.h>
int main (void)
{
char xinyouxi ='Y';
time_t seet =0, /*定义种子值*/
now= 0, /*定义游戏时间*/
now1=0; /*记录当前时间*/
int shuzichuan =0; /*记录数字串的长度*/
bool zhengque =true; /*确定游戏的正确性*/
int cishu = 0; /*玩家游戏的次数*/
int shuzi = 0; /*游戏玩家输入的数字*/
printf("这是一个猜数字的游戏!");
printf("\n每答对三次,难度就会增加!\n");
printf("按下回车键,进入游戏!\n");
scanf("%c",&xinyouxi);
do
{
zhengque = true ;
shuzichuan = 2;
now = clock();
cishu = 0;
while(zhengque)
{
shuzichuan += cishu++ % 3 == 0; /*确定游戏长度,答对三次后游戏加一位数*/
now1= clock(); /*记录游戏开始时间*/
seet= time(NULL); /*记录当前时间种子值*/
srand((unsigned int)seet);
for(int i=0 ; i<shuzichuan ; i++)
printf("%d ", rand() % 10);
for( ; clock()-now1<CLOCKS_PER_SEC ; );
printf("\r");
for(int i=0 ; i<shuzichuan ; i++)
printf(" ");
if(cishu == 1)
printf("\n请注意输入的格式,数字之间用空格间隔!\n");
else
printf("\r");
srand((unsigned int)seet);
for(int i=0 ; i<shuzichuan ; i++)
scanf("%d",&shuzi);
if(shuzi == rand() % 10)
printf("正确!\n");
else
{
printf("错误!\n");
zhengque = false;
}
}
now=(clock()-now)/CLOCKS_PER_SEC;
printf("你用的时间是%d秒.\n",now);
printf("你答对的次数是%d,成绩是%d\n。",cishu,cishu*10);
printf("是否再玩一次?(y/n):");
scanf(" %c",&xinyouxi);
}while(toupper(xinyouxi) == 'Y');
return 0;
}









