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