fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. void random(int *broad[4][4]){
  5. int finish = 1;
  6. while (finish)
  7. {
  8. if (broad[rand() % 4][rand() % 4] == 0) {
  9. broad[rand() % 4][rand() % 4] = 2;
  10. break;
  11. }
  12. else
  13. continue;
  14. }
  15.  
  16.  
  17. }
  18. void updata_broad(int broad[4][4]) {
  19. system("cls");
  20. for (int i = 0; i < 4; i++) {
  21. for (int j = 0; j < 4; j++)
  22. printf("%d ", broad[i][j]);
  23. printf("\n");
  24. }
  25. }
  26. int main() {
  27. int broad[4][4], gameset = 1;
  28. char move[1];
  29. printf("遊戲說明 輸入w(上)s(下)a(左)d(右)\n");
  30. for (int i = 0; i < 4; i++) // 初始化遊戲盤
  31. for (int j = 0; j < 4; j++)
  32. broad[i][j] = 0;
  33. while (gameset) {
  34.  
  35. //gameset = 0;
  36. scanf("%1s",move);
  37. random(broad);
  38. updata_broad(broad);
  39. }
  40. }
Time limit exceeded #stdin #stdout #stderr 5s 2924KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found
sh: 1: cls: not found