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