fork download
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <windows.h>
  4. #include <time.h>
  5. #define N 3//定義一個常數N,用來當做題目的初始設定
  6. void Clock(void);
  7. //遊戲程式
  8. void Game(int &i){
  9. char Quiz[13]={};//題目
  10. char Ans[13]={};//玩家輸入答案
  11. int j;//計數器j
  12. srand(time(NULL));//打亂亂數
  13. for(j=0;j<N+i;j++){//設定題目
  14. Quiz[j]=(65+rand()%26);
  15. }
  16. printf("*** Quiz %2d ***\n*** Ready!! ***\n",i+1);//列印題目
  17. system("pause");//pause
  18. printf("*** %s ***\n",Quiz);//列印題目
  19. Clock();//倒數計時
  20. system("cls");//清除畫面
  21. printf("Time up!\n");
  22. printf("請輸入解答\n");
  23. HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE);
  24. FlushConsoleInputBuffer(hInput);//清除預先輸入的答案
  25. fgets(Ans, 13, stdin);//玩家輸入答案
  26. rewind(stdin);
  27. if(strncmp(Quiz,Ans,N+i)==0)//驗證答案
  28. {
  29. i++;
  30. printf("答案正確!\n");
  31. if(N+i<13){
  32. Game(i);
  33. }//if(N+i<13)
  34. }else{
  35. printf("測驗結束!\n");
  36. }//if-else
  37. }//Game
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:3:21: fatal error: windows.h: No such file or directory
compilation terminated.
stdout
Standard output is empty