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