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

15 0
22 0