我什至不知道如何使这项工作!所以我在这里编码了这个东西,在它要求输入的部分,我什么都不能输入!请 hhelp T_T 我正在做的是一个问答时间程序,用户只能在规定的时间限制内回答问题。这是我的代码
#include <stdio.h>
#include "engine.h"
void level2(){
system("cls");
printf("Level 2 \n\n\n");
timer();
if ( time_limit >=0 ) {
printf("BOO");
}
}
int level1() {
char answer;
printf("Hello? \n\n");
scanf("%c",&answer);
time_limit = 20;
timer();
}
int rules() {
time_limit = 15;
system("cls");
printf(" Game Rules \n\n");
printf(" 1. You only have 5 seconds to guess what the correct answer for the question! \n");
}
int credits() {
int menu;
printf(" Coded by : \n");
printf("Lady Dianne Vertucci");
}
int main() {
int menu;
printf("TR \n ");
printf("1. Play \n");
printf("2. Credits \n");
scanf("%d",&menu);
switch (menu) {
case 1:
level1();
break;
case 2:
credits();
break;
default:
printf("Please choose a valid option 'tard");
break;
}
getch();
return 0;
}
这是engine.h
#ifndef _ENGINE_H_
#define _ENGINE_H_
static int time_limit = 0;
extern int time_limit;
static int score = 0;
extern int score;
int timer() {
while (time_limit !=0)
{
time_limit--;
printf("%02d\r",time_limit);
sleep(1000);
}
}
#endif