Matrisalar bilan ishlashga doir turli dasturlar


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

Matrisalar bilan ishlashga doir turli dasturlar

1-masala. 3ta qator va 4ta ustunga ega A matrisa berilgan. Shu matrisaning eng kichik elementini va uning indeksini topish, hamda shu element turgan qatorni massiv shaklida chiqarish dasturini tuzing.

# include # include void main ( ) { float a[3][4] = {{1.1, -2,0.3,4},{44,5.3,6.9,71},{7,8.8,9,1}}, i, j, k, h, min, b[4]; min = a[0][0]; for (i=0; i<3; i++) for (j=0; j<4; j++) { if ( a[ i ][ j ] < min) { min = a[ i ][ j ]; k = i; h = j; } } cout << “min=”<

2-masala. Matrisani transponirlash uchun dastur tuzing. Transponirlash deb ustun va satr elementlarining o’zaro o’rin almashishiga aytiladi, ya’ni

# include # include void main ( ) { int a[3][3] = {{1,2,3},{4,5,6},{7,8,9}}, b[3][3], i, j; for ( i=0; i<3; i++) { for ( j=0; j<3; j++) { b[ i ][ j ] = a[ j ][ i ]; cout <<”b[“<


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