C语言数字记忆小游戏,望采纳
#include
#include
#include
#include
#define TURE 1
#define FALSE 0
void main()
{
char another_name='Y';
char another_game='Y';
int correct='TRUE';
int counter=0;
int sequence_length=0;
int i=0;
long int seed=0;
int number=0;
long int now=0;
long time_taken=0;
int clock_per_sec;
printf("\n---------------------------------记忆小游戏--------------------------------------------\n");
printf("请牢记屏幕上出现的没一个数字,并在规定时间内输入您记下的数字。\n");
printf("回车开始游戏。\n");
scanf("%c",&another_game);
do
{
correct='TRUE';
counter=0;
sequence_length=2;
time_taken=clock();
while(correct)
{
sequence_length+=(counter++%3==0);
seed=time(NULL);
now=clock();
srand((int)seed);
for(i=0;i<=sequence_length;i++)
printf("%d",rand()%10);
for(;clock()-nowprintf("\r");
for(i=0;i<=sequence_length;i++)
printf("");
if(counter==1)
printf("\n输入您记住的数字,以空格隔开。\n");
else
printf("\r");
srand((int)seed);
for(i=0;i<=sequence_length;i++)
{
scanf("%d",&number);
if(number!=rand()%10)
{
correct=FALSE;
break;
}
}
printf("%s\n",correct?"正确!":"错误!");
}
time_taken=(clock()-time_taken)/clock_per_sec;
printf("\n您的成绩是:%d",--counter*100/time_taken);
fflush(stdin);
printf("\n是否继续游戏?(Y/N)?\n");
scanf("%c",&another_game);
}
while(another_game=='y'||another_game=='Y');
}
小子vsdgfwetgdg
小子vsdgfwet