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