fork download
  1.  
  2. #include <stdio.h>
  3.  
  4. int main(void)
  5. {
  6. int x[2][3] = {
  7. {1, 2, 3},
  8. {4, 5, 6}
  9. };
  10.  
  11. int y[3][2] = {
  12. {6, 5},
  13. {4, 3},
  14. {2, 1}
  15. };
  16.  
  17. int z[2][2] = {
  18. {10, 6},
  19. {4, 9}
  20. };
  21.  
  22. int ans[2][2];
  23.  
  24. cal_array(x, y, z, ans);
  25. for (int i = 0; i < 2; i++) {
  26. for (int j = 0; j < 2; j++) {
  27. printf("%d ", ans[i][j]);
  28. }
  29. printf("\n");
  30. }
  31.  
  32. return 0;
  33. }
  34.  
  35. void cal_array(const int (*x)[3], const int (*y)[2],
  36. const int (*z)[2], int (*ans)[2])
  37. {
  38. int i, j, k;
  39. for (i = 0; i < 2; i++) {
  40. for (j = 0; j < 2; j++) {
  41. ans[i][j] = 0;
  42.  
  43. for (k = 0; k < 3; k++) {
  44. ans[i][j] += x[i][k] * y[k][j];
  45. }
  46. ans[i][j] += z[i][j];
  47. }
  48. }
  49. }
  50.  
  51.  
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
30 20 
60 50