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