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]={0,1,2,3,4,5};
  6. int ans[2][3]={0};
  7. cal_array(x,y,ans);
  8.  
  9. return 0;
  10. }
  11. void cal_array(const int (*x)[3], const int (*y)[3], int (*ans)[3] ){
  12. printf("add\n");
  13. for(int i=0;i<2;i++){
  14. for(int j=0;j<3;j++){
  15. ans[i][j]=(x[i][j]+y[i][j]);
  16. printf("%d ",ans[i][j]);
  17. }
  18. putchar('\n');
  19. }
  20. putchar('\n');
  21. printf("sub\n");
  22. for(int i=0;i<2;i++){
  23. for(int j=0;j<3;j++){
  24. ans[i][j]=(x[i][j]-y[i][j]);
  25. printf("%d ",ans[i][j]);
  26. }
  27. putchar('\n');
  28. }
  29. putchar('\n');
  30.  
  31. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
add
1 3 5 
7 9 11 

sub
1 1 1 
1 1 1