题目:输入一个2*3的整数矩阵和一个3*2的整数矩阵,请使用指针数组实现这两个矩阵的相乘。! r8 l# c) Q5 C1 s* \; k
#include<stdio.h>- P+ b8 t( m9 _
main()
- g. B9 @* l+ L: K+ N' y" P{static int a[2][3],b[3][2],result[2][2];
* z/ O% ?0 ]! ^& Hint *p[3];$ ?0 O0 i. h3 m2 f/ @7 a
p[0]=a[0];p[1]=b[0];p[2]=result[0];
1 g! f7 {2 B1 {& qprintf("\n the 1st matrix;\n");
' C& V, U% S% E7 Q* ~for(int i=0;i<2;i++)
0 X H5 M+ G; `! i- e, U+ C0 j, P{printf("new line:\n");2 h' w% D* ?4 t5 M7 E
for(int j=0;j<3;j++) [; g! v* h# D" y( f6 v4 d) X
scanf("%d",p[0]+3*i+j);9 I6 P2 l$ Z7 f1 e) G0 b2 f; V9 L0 M
}
# P/ R9 i) W/ i$ s. g5 Rprintf("\n the 2st matrix;\n");6 C+ q: b- J3 x$ a/ _/ P1 u( w
for(int i=0;i<3;i++)
1 n7 L8 X- h7 y1 m {{printf("new line:\n");
; L7 M4 ~1 s0 t' Ifor(int j=0;j<2;j++)
/ ?' C( b% A0 V lscanf("%d",p[1]+2*i+j);! e" }7 i" O% `, H4 e- b6 h
}
/ b4 v% {) M" c; A$ R# ^/以下的开始相乘/
# e- S W6 ?7 C; {& H) Bfor(int i=0;i<2;i++)# g8 F: z9 A( K, f# r: \: _
for(int j=0;j<3;j++)
, e. |8 y3 U3 @- L b. u% u6 Hfor(int k=0;k<2;k++). X. V' m/ D' L* b" U0 D
*(p[2]+2*i+k)+=*(p[0]=3*i+j)*(*(p[1]+2*j+k));
5 ^1 A* @! z2 ], |for(int i=0;i<2;i++)
3 I' u4 o) [5 H9 w% Y{printf("\n");
9 K7 S- n l6 Tfor(int j=0;j<2;j++)+ F" q- T/ [# I9 G6 Y2 W$ t6 _
printf("%d,",*(p[2]+2*i+j));
) ?: L* H4 ~0 L; }% Y) D}
. Y& z/ I& e7 z/ _7 J. S1 r2 g# @7 r}; m" V3 }! @3 s! t" r% h3 V
完毕。就是相乘的那一段不明白,请指教( o# c; c/ W9 Q1 \6 e