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