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