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