Matricos daugyba C

Matricos daugyba C

Matricos daugyba C: Mes galime sudėti, atimti, dauginti ir padalyti 2 matricas. Norėdami tai padaryti, iš vartotojo gauname eilutės numerį, stulpelio numerį, pirmuosius matricos elementus ir antrosios matricos elementus. Tada atliekame vartotojo įvestų matricų dauginimą.

Matricos daugyboje pirmoji matrica vienos eilutės elementas padauginamas iš antrosios matricos visi stulpelio elementai .

Pabandykime suprasti matricos dauginimą 2*2 ir 3*3 matricos pagal žemiau pateiktą paveikslą:

matricos daugybos programa c

Pažiūrėkime matricos daugybos programą 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=
&apos;); for(i=0;i<r;i++) { for(j="0;j&lt;c;j++)" scanf('%d',&a[i][j]); } printf('enter the second matrix element="
&apos;);" for(i="0;i&lt;r;i++)" scanf('%d',&b[i][j]); printf('multiply of mul[i][j]="0;" for(k="0;k&lt;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&apos;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++)> 

Pabandykime suprasti matricos dauginimą 3*3 ir 3*3 matricos pagal žemiau pateiktą paveikslą:

matricos daugyba c