c代码记忆猜谜游戏哪里错了
#include<stdio.h>#include<ctype.h>
#include<stdbool.h>
#include<stdlib.h>
#include<time.h>
int main(void)
{
char another_game='Y';
const unsigned int DELAY=1;
bool correct=true;
unsigned int tries=0;
unsigned int digits=0;
time_t seed=0;
unsigned int number=0;
time_t wait_start=0;
clock_t start_time=0;
unsigned int sorce=0;
unsigned int total_digits=0;
unsigned int game_time=0;
printf("\n To play Simple Simon,");
printf("watch the screen for a sequence of digits.");
printf("\n The computer will remove them ,and then prompt you ");
printf("enter the same sequence");
printf("\nn When you dou,you must put spaces between the digits.\n");
printf( "\n good luck, press enter to play\n");
scanf("%c",&another_game);
do
{
correct=true;
tries=0;
digits=2;
start_time=clock();
while(correct )
{
++tries;
wait_start=clock();
srand(time(&seed));
for(unsigned int i=1;i<=digits;++i)
printf("%u",rand()%10);
for(;clock()-wait_start<DELAY*CLOCKS_PER_SEC;);
printf("\r");
for(unsigned int i=1;i<=digits;++i)
printf(" ");
if(tries==1)
printf("\n Now you enter the squence- don't forget""the space \n");
else
printf("\r");
srand(seed);
for(unsigned int i=1;i<=digits;++i)
{
scanf("%u",&number);
if ( number != rand()%10)
{
correct=false;
break;
}
}
if(correct&&((tries%3)==0))
++digits;
printf("%s \n",correct ? "correct!":"wrong!");
}
sorce=10*(digits-((tries%3)==1));
total_digits=digits*(((tries%3)==0)?3:tries%3);
if(digits>2)
total_digits+=3*((digits-1)*(digits-2)/2-1);
game_time=(clock()-start_time)/CLOCKS_PER_SEC-tries*DELAY;
if(total_digits>game_time)
sorce+=10*(game_time-total_digits);
printf("\n\n Game time was %useconds.Your score is %u.",game_time,sorce);
fflush(stdin);
printf("\n Do you want to play again(y/n):");
scanf("%c",&another_game);
}while (toupper(another_game)=='Y');
return 0;
}