该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
一下是源代码,刚开始自己做的,但一直出现问题(无报错),所以直接复制的答案,然后用gcc -std=c99 -O3 -Wall进行编译,但问题依旧,所以只能向高手求助了。这是一个猜数字的游戏,开始时,游戏会输出2个随机数字,停留1秒,然后删除,等待用户输入正确数字。
/* Program 4.12 Simple Simon */
#include /* For input and output */
#include /* For toupper() function */
#include /* For bool, true, false */
#include /* For rand() and srand() */
#include /* For time() and clock() */
int main(void)
{
char another_game = 'Y';
int correct = false;
int counter = 0;
int sequence_length = 0; /* Number of digits in a sequence */
time_t seed = 0; /* Seed value for random number sequence */
int number = 0; /* Stores an input digit */
time_t now = 0; /* Stores current time - seed for random values */
int time_taken = 0; /* Time taken for game in seconds */
printf("\nTo play Simple Simon, ");
printf("watch the screen for a sequence of digits.");
printf("\nWatch carefully, as the digits are only displayed"
" for a second! ");
printf("\nThe computer will remove them, and then prompt you ");
printf("to enter the same sequence.");
printf("\nWhen you do, you must put spaces between the digits. \n");
printf("\nGood Luck!\nPress Enter to play\n");