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