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