כפל מטריצה ב-C
כפל מטריצה ב-C: אנו יכולים להוסיף, להחסיר, להכפיל ולחלק 2 מטריצות. לשם כך, אנו לוקחים קלט מהמשתמש עבור מספר שורה, מספר עמודה, רכיבי מטריצה ראשונה ורכיבי מטריצה שניים. לאחר מכן אנו מבצעים כפל על המטריצות שהזין המשתמש.
בכפל מטריצה מטריצה ראשונה אלמנט שורה אחת מוכפל במטריצה השנייה כל רכיבי העמודה .
בואו ננסה להבין את הכפל המטריצת של 2*2 ו-3*3 מטריצות לפי האיור המופיע להלן:
בוא נראה את תוכנית הכפל המטריצה ב-C.
#include #include int main(){ int a[10][10],b[10][10],mul[10][10],r,c,i,j,k; system('cls'); printf('enter the number of row='); scanf('%d',&r); printf('enter the number of column='); scanf('%d',&c); printf('enter the first matrix element=
'); for(i=0;i<r;i++) { for(j="0;j<c;j++)" scanf('%d',&a[i][j]); } printf('enter the second matrix element="
');" for(i="0;i<r;i++)" scanf('%d',&b[i][j]); printf('multiply of mul[i][j]="0;" for(k="0;k<c;k++)" mul[i][j]+="a[i][k]*b[k][j];" for printing result printf('%d ',mul[i][j]); printf('
'); return 0; < pre> <p> <strong>Output:</strong> </p> <pre> enter the number of row=3 enter the number of column=3 enter the first matrix element= 1 1 1 2 2 2 3 3 3 enter the second matrix element= 1 1 1 2 2 2 3 3 3 multiply of the matrix= 6 6 6 12 12 12 18 18 18 </pre> <p>Let's try to understand the matrix multiplication of <strong>3*3 and 3*3</strong> matrices by the figure given below:</p> <img src="//techcodeview.com/img/c-programs/01/matrix-multiplication-c-2.webp" alt="matrix multiplication in c"> <hr></r;i++)> בואו ננסה להבין את הכפל המטריצת של 3*3 ו-3*3 מטריצות לפי האיור המופיע להלן: