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