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. calculate(a);
  8. return 0;
  9. }
  10.  
  11. void calculate(int (*a)[4]){
  12. int x,y;
  13. int sum;
  14.  
  15. for(x=0;x<3;x++){
  16. sum=0;
  17.  
  18. for(y=0;y<4;y++){
  19. sum+=a[x][y];
  20. }
  21.  
  22. printf("%d行目の合計は%dです\n",x+1,sum);
  23.  
  24. }
  25. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
1行目の合計は10です
2行目の合計は26です
3行目の合計は42です