จงเขียนโปรแกรมหาผลคูณเมตริกซ์ เอ กับ บี | เว็บบอร์ด วิชาการ.คอม

จงเขียนโปรแกรมหาผลคูณเมตริกซ์ เอ กับ บี

โพสต์เมื่อ: 13:23 วันที่ 17 มิ.ย. 2551         ชมแล้ว: 4,730 ตอบแล้ว: 3
วิชาการ >> กระทู้ >> ทั่วไป

จงเขียนโปรแกรมหาผลคูณเมตริกซ์ A,B โดยรับค่าจากคีร์บอร์ด โดยสามารถหาผลคูณขนาดต่างๆ ตามที่ต้องการได้


เขียนด้วยภาษาซีหรือภาษาอื่นๆ ตามที่ถนัด


Example ขนาด 2x2


A =[ 1 2


       1 3]


B=[0 2


    1 1]


AxB =[2 4


         3 5]


 



narongsak_a
ร่วมแบ่งปัน18 ครั้ง - ดาว 50 ดวง





จำนวน 3 ความเห็น, หน้าที่ | -1-
ความเห็นเพิ่มเติมที่ 1 21 มิ.ย. 2551 (01:00)
<P>&nbsp;</P>

<P>int m1[10][10],m2[10][10],r1,r2,c1,c2;</P>

<P>//enter number of rows and columns for matrix A<BR>//enter number of rows and columns for matrix B<BR><BR>if(r2!=c1)<BR>&nbsp;{<BR>&nbsp; &nbsp;getch();<BR>&nbsp;&nbsp; exit(0);<BR>&nbsp;}<BR><BR>//enter elements for matrix A and B<BR>for(i=0;i&lt;r1;i++)<BR>for(j=0;j&lt;c1;j++)<BR>scanf("%d",&amp;m1[i][j]);<BR><BR>for(i=0;i&lt;r2;i++)<BR>for(j=0;j&lt;c2;j++)<BR>scanf("%d",&amp;m2[i][j]);</P>

<P>//multiple of matrices A and B<BR>for(i=0;i&lt;r1;i++)<BR>for(j=0;j&lt;c2;j++)<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp; mul[i][j]=0;<BR>&nbsp;&nbsp;&nbsp; for(m=0;m&lt;c1;m++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mul[i][j]=mul[i][j]+m1[i][m]*m2[m][j];<BR>&nbsp;}<BR>/*สำหรับ output&nbsp;แบบ<BR>A=&nbsp;&nbsp;x&nbsp;&nbsp;&nbsp;&nbsp; x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x<BR>*/<BR>printf("nMatrix A = n");<BR>for(i=0;i&lt;r1;i++)<BR>{<BR>&nbsp; for(j=0;j&lt;c1;j++)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; printf("t%d",m1[i][j]);<BR>&nbsp;&nbsp; }<BR>&nbsp; printf("n");<BR>&nbsp;}</P>

<P>//ผลคุณก็ทำแบบเดียวกัน</P>
sapa (IP:122.167.156.79)

ความเห็นเพิ่มเติมที่ 2 21 มิ.ย. 2551 (01:03)
<P><FONT color=#000099>&nbsp;</FONT></P>

<P><FONT face="arial, helvetica, sans-serif" color=#000099 size=3>int m1[10][10],m2[10][10],r1,r2,c1,c2;</FONT></P>

<P><FONT face="arial, helvetica, sans-serif" color=#000099 size=3>//enter number of rows and columns for matrix A<BR>//enter number of rows and columns for matrix B<BR><BR>if(r2!=c1)<BR>&nbsp;{<BR>&nbsp; &nbsp;getch();<BR>&nbsp;&nbsp; exit(0);<BR>&nbsp;}<BR><BR>//enter elements for matrix A and B<BR>for(i=0;i&lt;r1;i++)<BR>for(j=0;j&lt;c1;j++)<BR>scanf("%d",&amp;m1[i][j]);<BR><BR>for(i=0;i&lt;r2;i++)<BR>for(j=0;j&lt;c2;j++)<BR>scanf("%d",&amp;m2[i][j]);</FONT></P>

<P><FONT face="arial, helvetica, sans-serif" color=#000099 size=3>//multiple of matrices A and B<BR>for(i=0;i&lt;r1;i++)<BR>for(j=0;j&lt;c2;j++)<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp; mul[i][j]=0;<BR>&nbsp;&nbsp;&nbsp; for(m=0;m&lt;c1;m++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mul[i][j]=mul[i][j]+m1[i][m]*m2[m][j];<BR>&nbsp;}<BR>/*สำหรับ output&nbsp;แบบ<BR>A=&nbsp;&nbsp;x&nbsp;&nbsp;&nbsp;&nbsp; x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x<BR>*/<BR>printf("nMatrix A = n");<BR>for(i=0;i&lt;r1;i++)<BR>{<BR>&nbsp; for(j=0;j&lt;c1;j++)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; printf("t%d",m1[i][j]);<BR>&nbsp;&nbsp; }<BR>&nbsp; printf("n");<BR>&nbsp;}</FONT></P>

<P><FONT face="arial, helvetica, sans-serif" color=#000099 size=3></FONT>&nbsp;</P>
nes (IP:122.167.156.79)

ความเห็นเพิ่มเติมที่ 3 21 มิ.ย. 2551 (01:06)
<P>[code]</P>

<P>&nbsp;</P>

<P>int m1[10][10],m2[10][10],r1,r2,c1,c2;</P>

<P>//enter number of rows and columns for matrix A<BR>//enter number of rows and columns for matrix B</P>

<P>if(r2!=c1)<BR>&nbsp;{<BR>&nbsp;&nbsp; getch();<BR>&nbsp;&nbsp; exit(0);<BR>&nbsp;}</P>

<P>//enter elements for matrix A and B<BR>for(i=0;i<R1;I++)<BR>for(j=0;j<C1;J++)<BR>scanf("%d",&amp;m1[i][j]);</P>

<P>for(i=0;i<R2;I++)<BR>for(j=0;j<C2;J++)<BR>scanf("%d",&amp;m2[i][j]);</P>

<P>//multiple of matrices A and B<BR>for(i=0;i<R1;I++)<BR>for(j=0;j<C2;J++)<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp; mul[i][j]=0;<BR>&nbsp;&nbsp;&nbsp; for(m=0;m<C1;M++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mul[i][j]=mul[i][j]+m1[i][m]*m2[m][j];<BR>&nbsp;}<BR>/*สำหรับ output แบบ<BR>A=&nbsp; x&nbsp;&nbsp;&nbsp;&nbsp; x<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x&nbsp;&nbsp;&nbsp;&nbsp; x<BR>*/<BR>printf("nMatrix A = n");<BR>for(i=0;i<R1;I++)<BR>{<BR>&nbsp; for(j=0;j<C1;J++)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; printf("t%d",m1[i][j]);<BR>&nbsp;&nbsp; }<BR>&nbsp; printf("n");<BR>&nbsp;}</P>

<P>//ผลคุณก็ทำแบบเดียวกัน<BR></P>

<P>&nbsp;</P>

<P>[/code]</P>
sapa (IP:122.167.156.79)

จำไว้ตลอด

ความเห็นเพิ่มเติม วิชาการ.คอม
ชื่อ / email:
ข้อความ

กรุณาล๊อกอินก่อน เพื่อโพสต์รูปภาพ และ ใช้ LaTex ค่ะ สมัครสมาชิกฟรีตลอดชีพที่นี่
กรอกตัวอักษรตามภาพ
ตัวช่วย 1: CafeCode วิธีการใช้
ตัวช่วย 2: VSmilies วิธีการใช้
ตัวช่วย 3: พจนานุกรมไทย ออนไลน์ ฉบับราชบัณฑิต
ตัวช่วย 4 : dictionary ไทย<=>อังกฤษ ออนไลน์ จาก NECTEC
ตัวช่วย 5 : ดาวน์โหลด โปรแกรมช่วยพิมพ์ Latex เพื่อแสดงสมการบนวิชาการ.คอม
Google  
ผู้สนับสนุน คลิีกดูสถิติ
อีเมล : star@vcharkarn.com
โทรศัพท์ : 02-9620127
Creative Commons License สงวนสิทธิ์บางประการภายใต้สัญญาอนุญาต ครีเอทีฟคอมมอนส์ แสดงที่มา-ไม่ใช้เพื่อการค้า-ไม่ดัดแปลง 3.0 ประเทศไทย.
ท่านสามารถนำเนื้อหาในส่วนบทความไปใช้ แสดง เผยแพร่ โดยต้องอ้างอิงที่มา ห้ามใช้เพื่อการค้าและห้ามดัดแปลง
Page generated in0.0218 seconds !