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