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