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