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