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