fork download
  1.  
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include <time.h>
  5.  
  6. void random(int *broad[4][4]) {
  7. int finish = 1,x,y;
  8.  
  9. while (finish)
  10. {
  11. srand(time(NULL));
  12. x = rand() % 4;
  13. srand(time(NULL));
  14. y = rand() % 4;
  15. if (broad[x][y] == 0) {
  16. broad[x][y] = 2;
  17. break;
  18. }
  19.  
  20.  
  21. }
  22.  
  23.  
  24. }
  25. void updata_broad(int broad[4][4]) {
  26. system("cls");
  27. for (int i = 0; i < 4; i++) {
  28. for (int j = 0; j < 4; j++)
  29. printf("%d ", broad[i][j]);
  30. printf("\n");
  31. }
  32. }
  33. int main() {
  34. int broad[4][4], gameset = 1;
  35. char move[1];
  36. printf("遊戲說明 輸入w(上)s(下)a(左)d(右)\n");
  37. for (int i = 0; i < 4; i++) // 初始化遊戲盤
  38. for (int j = 0; j < 4; j++)
  39. broad[i][j] = 0;
  40. while (gameset) {
  41.  
  42. //gameset = 0;
  43. scanf("%s", move);
  44. random(&broad);
  45. updata_broad(broad);
  46. }
  47. }
Time limit exceeded #stdin #stdout #stderr 5s 2172KB
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