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