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