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.
Do'stlaringiz bilan baham: |