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