求高手帮我看看我写的程序!
#include<stdio.h>#include<ctype.h>
#include<stdlib.h>
#include<time.h>
#include<stdbool.h>
int main(void)
{
/*局部变量生成池*/
char another_game = 'Y';
bool correct = true;
int counter = 0;
int sequence_length = 0;
time_t seed = 0;
int number = 0;
printf("\n这是一个简单的记忆游戏,");
printf("注意看屏幕上的数组.");
printf("\n仔细观察,因为数字只显示一秒钟!");
printf("\n计算机将删除这些数组,然后提示你输入相同的数组.");
printf("\nWhen you do, you must put spaces between the digits. \n");
printf("祝你好运!\n按回车键进行游戏\n");
scanf("%c",&another_game);
do
{
correct = true;
counter = 0;
sequence_length = 2;
while(correct)
{
sequence_length += counter++%3 == 0;
seed = time(NULL);
srand((unsigned int)seed);
for(int i = 1; i<=sequence_length; i++)
printf("%d",rand()%10);
srand((unsigned int)seed);
for(int i = 1; i<= sequence_length;i++)
{
scanf("%d",&number);
if(number != rand() %10)
{
correct = false;
break;
}
}
printf("%s\n",correct ? "Correct!" : "Wrong!");
}
printf("\nDo you want to play again (y/n)?");
scanf("%c",&another_game);
}while(toupper(another_game) == 'Y');
return 0;
}
-----------------------------------------------------------------分割线----------------------------------------------------------------------
这段程序不能被编译,我用的是C-free编译器4.1版本,一编译就弹出没有stdbool.h函数有问题,拿到VC6.0里面编译也提示说没有stdbool.h这个函数,后来我去掉了#include<stdbool.h>这句倒是可以编译,可是居然编译出来的都是怪怪的感觉,生成的随即数字居然是3位数!我找了两天的错误了,实在是什么都找不出来,我快崩溃了,只能来这里求高手帮帮我了!