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