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. {
  4. int a,b,c;
  5. for(a=0;a<2;a++){
  6. for(b=0;b<2;b++){
  7. ans[a][b]=0;
  8. for(c=0;c<3;c++){
  9. ans[a][b]+=x[a][c]*y[c][b];
  10. }
  11. ans[a][b]+=z[a][b];
  12. }
  13. }
  14. }
  15.  
  16. int main(void) {
  17. const int x[2][3]={ {1,2,3},{4,5,6} },y[3][2]={ {6,5},{4,3},{2,1} };
  18. const int z[2][2]={ {10,6},{4,9} };
  19. int ans[2][2];
  20. cal_array(x,y,z,ans);
  21. int d,e;
  22. for(d=0;d<2;d++){
  23. for(e=0;e<2;e++){
  24. printf("%d ",ans[d][e]);
  25. }
  26. }
  27.  
  28. // your code goes here
  29. return 0;
  30. }
  31.  
  32.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
30 20 60 50