fork download
  1. #include<stdio.h>
  2. #include<time.h>
  3.  
  4. int main(void){
  5. int a[5][5];
  6.  
  7. int num;
  8. int max=99;
  9. int total=10;
  10. srand((unsigned)time(NULL));
  11. for(int i=0;i<=4;i++){
  12. for(int j=0;j<=4;j++){
  13. a[i][j]=rand() % 99+1;
  14. }
  15. }
  16.  
  17. for(int i=0;i<=4;i++){
  18. for(int j=0;j<=4;j++){
  19. printf(" %2d",a[i][j]);
  20. }
  21. printf("\n");
  22. }
  23.  
  24. for(int k=0; k<total; k++){
  25. num=rand() % max+1;
  26. printf("%2d/%d回目の数:",k+1,total);
  27. printf(" %d\n",num);
  28.  
  29. for(int i=0; i<=4; i++){
  30. for(int j=0; j<=4; j++){
  31. if(a[i][j]==num)
  32. a[i][j]==0;
  33. }
  34. }
  35.  
  36. for(int i=0; i<=4; i++){
  37. for(int j=0; j<=4; j++){
  38. if(a[i][j]==0){
  39. printf("**");
  40. }else{
  41. printf(" %2d",a[i][j]);
  42. }
  43. }
  44. printf("\n");
  45. }
  46.  
  47. }
  48.  
  49. return 0;
  50.  
  51. }
  52.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15
 1/10回目の数: 5
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15
 2/10回目の数: 29
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15
 3/10回目の数: 29
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15
 4/10回目の数: 28
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15
 5/10回目の数: 13
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15
 6/10回目の数: 42
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15
 7/10回目の数: 48
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15
 8/10回目の数: 38
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15
 9/10回目の数: 95
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15
10/10回目の数: 50
 21 27 56  2 80
 83  9 82 93 28
 37 67  1 44 88
 71 32 92 25 94
 42 29 96 34 15