fork download
  1. #include <stdio.h>
  2.  
  3. void calculate(int (*a)[4])
  4. {
  5. int i, j;
  6. int sum;
  7.  
  8. for (i = 0; i < 3; i++) {
  9.  
  10. sum = 0;
  11.  
  12. for (j = 0; j < 4; j++) {
  13. sum = sum + a[i][j];
  14. }
  15.  
  16. printf("行%dの合計 = %d\n", i, sum);
  17. }
  18. }
  19.  
  20. int main(void)
  21. {
  22. int a[3][4] = {
  23. {1, 2, 3, 4},
  24. {5, 6, 7, 8},
  25. {9, 10, 11, 12}
  26. };
  27.  
  28. calculate(a);
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
行0の合計 = 10
行1の合計 = 26
行2の合計 = 42