fork download
  1. #include <stdio.h>
  2.  
  3. void array_mul(int (*x)[2],int (*y)[2],int (*ans)[2])
  4. {
  5. for(int i=0;i<2;i++) //行
  6. {
  7. for(int j=0;j<2;j++) //列
  8. {
  9. ans[i][j] = 0;
  10. for(int d=0;d<2;d++)
  11. {
  12. ans[i][j] += x[i][d] * y[d][j];
  13. }
  14. }
  15. }
  16.  
  17.  
  18. }
  19.  
  20.  
  21. int main(void) {
  22. int ans[2][2];
  23. int x[2][2] = { {1,2},
  24. {3,4} };
  25. int y[2][2] = { {1,2},
  26. {3,4} };
  27. array_mul(x,y,ans);
  28. for(int k=0;k<2;k++)
  29. {
  30. for(int f=0;f<2;f++)
  31. {
  32. printf("%d ",ans[k][f]);
  33. }
  34. printf("\n");
  35. }
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
7 10 
15 22