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