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