fork download
  1. #include <stdio.h>
  2.  
  3. void cal_array(const int (*x)[3], const int (*y)[2], const int (*z)[2], int (*ans)[2]);
  4.  
  5. int main(void) {
  6.  
  7. int x[2][3]={
  8. {1,2,3},
  9. {4,5,6}
  10. };
  11. int y[3][2]={
  12. {6,5},
  13. {4,3},
  14. {2,1}
  15. };
  16. int z[2][2]={
  17. {10,6},
  18. {4,9}
  19. };
  20. int ans[2][2]={0};
  21.  
  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. printf(" %d",ans[i][j]);
  27. }
  28. printf("\n");
  29. }
  30. return 0;
  31. }
  32.  
  33. void cal_array(const int (*x)[3], const int (*y)[2], const int (*z)[2], int (*ans)[2]){
  34.  
  35. for(int i=0;i<2;i++){
  36. for(int j=0;j<2;j++){
  37. int a=0;
  38.  
  39. for(int k=0;k<3;k++){
  40. a+=x[i][k]*y[k][j];
  41. }
  42.  
  43. ans[i][j]=a+z[i][j];
  44. }
  45. }
  46. }
  47.  
  48.  
  49.  
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
 30 20
 60 50