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