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