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