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