fork 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()
  6. {
  7. int x[2][3]={1,2,3,4,5,6}, y[3][2]={6,5,4,3,2,1}, z[2][2]={10,6,4,9}, ans[2][2], m, n;
  8. cal_array(x,y,z,ans);
  9. for(m=0;m<2;m++){
  10. for(n=0;n<2;n++){
  11. printf("ans[%d][%d]=%d\n",m,n,ans[m][n]);
  12. }
  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 i,j,k,temp=0;
  19. for(i=0;i<2;i++){
  20. for(j=0;j<2;j++){
  21. temp = 0;
  22. for(k=0;k<3;k++){
  23. temp += x[i][k] * y[k][j];
  24. }
  25. ans[i][j] = temp + z[i][j];
  26. }
  27. }
  28. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
ans[0][0]=30
ans[0][1]=20
ans[1][0]=60
ans[1][1]=50