Matrisalar bilan ishlashga doir turli dasturlar


-masala. Matrisaning izini hisoblash dasturini tuzing. Matrisaning izi deb bosh diagonal elementlarinig yig’indisiga aytiladi


Download 85.43 Kb.
bet2/3
Sana16.11.2021
Hajmi85.43 Kb.
#175275
1   2   3
Bog'liq
Matritsaga doir dasturlar

3-masala. Matrisaning izini hisoblash dasturini tuzing. Matrisaning izi deb bosh diagonal elementlarinig yig’indisiga aytiladi.

(Xatosini toping!) # include //# include void main ( ) { int a[3][3] = {{3,4.5,6},{0.4,8,5.9},{9.2,6.5,88}}, s1=0; int i, j, k; for ( i=0; i <= 3; j++) s1 = s1 + a[ i ][ j ]; cout << ”s1=”<< s1 << end; getch ( ); return 0; }

1-variant: # include # include void main ( ) { float a[3][3] = {{3,4.5,6},{0.4,8,5.9},{9.2,6.5,88}}, s1=0; int i ; for ( i=0; i < 3; i++) s1 = s1 + a[ i ][ i ]; cout <<”s1=”<

2-variant: # include # include void main ( ) { float a[3][3] = {{3,4.5,6},{0.4,8,5.9},{9.2,6.5,88}}, s1=0; int i, j ; for ( i=0; i < 3; i++) for ( j=0; j < 3; j++) if ( i = = j) s1 = s1 + a[ i ][ j ]; cout <<”s1=”<

4-masala. 2 ta matrisa berilgan. Ularni o’zaro ko’paytirib yangi matrisa hosil qilish dasturini tuzing. Izoh: 1-matrisaning ustunlar soni 2-matrisaning satrlar soniga teng bo’lishi kerak.


Download 85.43 Kb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling