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 0.01s 5288KB
stdin
Standard input is empty
stdout
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33 22 87 75 69
 53 33  5 26 56
 1/10回目の数: 84
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33 22 87 75 69
 53 33  5 26 56
 2/10回目の数: 2
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33 22 87 75 69
 53 33  5 26 56
 3/10回目の数: 78
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33 22 87 75 69
 53 33  5 26 56
 4/10回目の数: 79
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33 22 87 75 69
 53 33  5 26 56
 5/10回目の数: 29
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33 22 87 75 69
 53 33  5 26 56
 6/10回目の数: 72
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33 22 87 75 69
 53 33  5 26 56
 7/10回目の数: 69
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33 22 87 75**
 53 33  5 26 56
 8/10回目の数: 75
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33 22 87****
 53 33  5 26 56
 9/10回目の数: 62
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33 22 87****
 53 33  5 26 56
10/10回目の数: 22
 89 47 90 53 31
  9 43 26 48 36
 74 58 44 15 91
 33** 87****
 53 33  5 26 56