fork download
  1. #include <stdio.h>
  2.  
  3.  
  4. int main(void)
  5. {
  6. int x[2][5] = {0};
  7.  
  8. int no;
  9. printf("すべての構成要素に代入する値:%d\n",no);
  10. scanf("%d", &no);
  11.  
  12. fill(x, 2, no);
  13.  
  14. printf("xの配列\n");
  15.  
  16. display(x, 2);
  17.  
  18. return 0;
  19. }
  20.  
  21. void fill(int m[2][5], int n, int v)
  22. {
  23. for (int i = 0; i < n; i++) {
  24. for (int j = 0; j < 5; j++) {
  25. m[i][j] = v;
  26. }
  27. }
  28. }
  29.  
  30. void display(const int m[2][5], int n)
  31. {
  32. for (int i = 0; i < n; i++) {
  33. for (int j = 0; j < 5; j++) {
  34. printf("%d ", m[i][j]);
  35. }
  36. putchar('\n');
  37. }
  38. }
  39.  
Success #stdin #stdout 0s 5320KB
stdin
56
stdout
すべての構成要素に代入する値:21996
xの配列
56 56 56 56 56 
56 56 56 56 56