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