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