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