fork(1) download
  1. #include <stdio.h>
  2. void cal_array(const int (*x)[3], const int (*y)[2], const int (*z)[2], int (*ans)[2]);
  3. void cal_array(const int (*x)[3], const int (*y)[2], const int (*z)[2], int (*ans)[2])
  4. {
  5. for (int i=0; i<2; i++){
  6. for (int j=0; j<2; j++){
  7. int sum=0;
  8. for (int k=0; k<3; k++){
  9. sum+=x[i][k]*y[k][j];
  10. }
  11. ans[i][j]=sum+z[i][j];
  12. }
  13. }
  14. }
  15.  
  16. int main (void)
  17. {
  18. int x[2][3]={{1,2,3}, {4,5,6}};
  19. int y[3][2]={{6,5},{4,3}, {2,1}};
  20. int z[2][2]={{10,6}, {4,9}};
  21. int ans[2][2];
  22. cal_array(x, y, z, ans);
  23.  
  24. for(int i=0; i<2; i++){
  25. for(int j=0; j<2; j++){
  26.  
  27. printf("%d ", ans[i][j]);
  28. }
  29. printf("\n");
  30. }
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
30 20 
60 50