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 5284KB
stdin
Standard input is empty
stdout
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7
 1/10回目の数: 4
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7
 2/10回目の数: 10
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7
 3/10回目の数: 51
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7
 4/10回目の数: 79
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7
 5/10回目の数: 48
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7
 6/10回目の数: 25
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7
 7/10回目の数: 21
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7
 8/10回目の数: 36
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7
 9/10回目の数: 47
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7
10/10回目の数: 87
 41 87 23 67 49
 90 27 69  2 44
 47 74 89 22 68
 71 78 17 90 22
 60 61 78  2  7