fork download
  1. #include <stdio.h>
  2. void cal_array(const int (*x)[3], const int (*y)[3], int (*ans)[3] );
  3. int main(void) {
  4. int x[2][3]={{1,2,3},{4,5,6}};
  5. int y[2][3]={{1,2,3},{4,5,6}};
  6. int ans[2][3]={0};
  7.  
  8. cal_array(x,y,ans);
  9.  
  10. return 0;
  11. }
  12. void cal_array(const int (*x)[3], const int (*y)[3], int (*ans)[3] ){
  13. printf("足し算\n");
  14. for(int i=0;i<2;i++){
  15. for(int j=0;j<3;j++){
  16. printf("%d ",x[i][j]+y[i][j]);
  17. }
  18. putchar('\n');
  19. }
  20. printf("引き算\n");
  21. for(int i=0;i<2;i++){
  22. for(int j=0;j<3;j++){
  23. printf("%d ",x[i][j]-y[i][j]);
  24. }
  25. putchar('\n');
  26. }
  27. }
  28.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
足し算
2 4 6 
8 10 12 
引き算
0 0 0 
0 0 0