展开全部
C语言数字记忆小游戏,望采纳
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<time.h>
#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()-now<clock_per_sec;);
printf("\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');
}
追答
好好学习
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询