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