fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h> /*randまたはsrandを使うのに必要*/
  3. #include <time.h> /*timeを使うために必要*/
  4.  
  5. int main(void) {
  6. int a[5][5];
  7. int num;
  8. int max = 99;
  9. int total = 10;
  10. srand((unsigned)time(NULL));
  11.  
  12. for(int i=0; i<total; i++){
  13. num = rand() % max + 1;
  14. printf("%2d/%d回目の数:", i+1, total);
  15. printf("%d\n", num);
  16.  
  17. for(int i=0; i<5; i++){
  18. for(int j=0; j<5; j++){
  19. if(a[i][j] == num){
  20. a[i][j] = 0;
  21. }
  22. }
  23. }
  24.  
  25. for(int i=0; i<5; i++){
  26. for(int j=0; j<5; j++){
  27. if(a[i][j] == 0){
  28. printf("** ");
  29. }
  30. else{
  31. printf("%2d ", a[i][j]);
  32. }
  33. }
  34. printf("\n");
  35. }
  36. }
  37.  
  38.  
  39. for(int i=0; i<5; i++){
  40. for(int j=0; j<5; j++){
  41. if(a[i][j] == 0) {
  42. printf("** ");
  43. }
  44. else{
  45. printf("%2d ", a[i][j]);
  46. }
  47. }
  48. printf("¥n");
  49. }
  50. return 0;
  51. }
  52.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
 1/10回目の数:28
** ** ** ** -927137847 
32765 ** ** ** ** 
** ** ** ** 15774463 
** 194 ** -927140698 32765 
 1 ** 336141141 5371 ** 
 2/10回目の数:17
** ** ** ** -927137847 
32765 ** ** ** ** 
** ** ** ** 15774463 
** 194 ** -927140698 32765 
 1 ** 336141141 5371 ** 
 3/10回目の数:64
** ** ** ** -927137847 
32765 ** ** ** ** 
** ** ** ** 15774463 
** 194 ** -927140698 32765 
 1 ** 336141141 5371 ** 
 4/10回目の数:83
** ** ** ** -927137847 
32765 ** ** ** ** 
** ** ** ** 15774463 
** 194 ** -927140698 32765 
 1 ** 336141141 5371 ** 
 5/10回目の数:71
** ** ** ** -927137847 
32765 ** ** ** ** 
** ** ** ** 15774463 
** 194 ** -927140698 32765 
 1 ** 336141141 5371 ** 
 6/10回目の数:62
** ** ** ** -927137847 
32765 ** ** ** ** 
** ** ** ** 15774463 
** 194 ** -927140698 32765 
 1 ** 336141141 5371 ** 
 7/10回目の数:71
** ** ** ** -927137847 
32765 ** ** ** ** 
** ** ** ** 15774463 
** 194 ** -927140698 32765 
 1 ** 336141141 5371 ** 
 8/10回目の数:94
** ** ** ** -927137847 
32765 ** ** ** ** 
** ** ** ** 15774463 
** 194 ** -927140698 32765 
 1 ** 336141141 5371 ** 
 9/10回目の数:54
** ** ** ** -927137847 
32765 ** ** ** ** 
** ** ** ** 15774463 
** 194 ** -927140698 32765 
 1 ** 336141141 5371 ** 
10/10回目の数:34
** ** ** ** -927137847 
32765 ** ** ** ** 
** ** ** ** 15774463 
** 194 ** -927140698 32765 
 1 ** 336141141 5371 ** 
** ** ** ** -927137847 ¥n32765 ** ** ** ** ¥n** ** ** ** 15774463 ¥n** 194 ** -927140698 32765 ¥n 1 ** 336141141 5371 ** ¥n