8-Mavzu. Bir o‘lchovli va ikki o`lchovli massivlar ustida amallar bajarishga doir dasturlar tuzish


Misollar 1. ni hisoblash dasturini tuzing. Dasturi


Download 173.17 Kb.
bet5/5
Sana22.04.2023
Hajmi173.17 Kb.
#1380860
1   2   3   4   5
Bog'liq
Laboratoriya ishi 8 (1)

Misollar
1. ni hisoblash dasturini tuzing.


Dasturi:
#include
#include
using namespace std;
int main ()
{
float a[3][5], S,P; int i,j;
cout<<"Massiv elementini kiriting:"< for (i=0; i<3; i++)
for (j=1; j<5; j++)
cin>>a[i][j];
S=0;
for (i=0; i<3; i++)
{
P=1;
for (j=1; j<5; j++)
P=P*pow(a[i][j],0.5);
S=S+P;
}
cout<<"S="< return 0;
}


Dastur natijasi:

8.4-rasm. Dastur natijasi


Ikki o‘lchovli dinamik massivlar. Ikki o‘lchovli dinamik massiv umumiy ko‘rinishda quyidagicha ikki bosqichda e’lon qilinadi:
t **b;
bu yerda:
bmassiv nomi;
t – massiv elementlari turi.
Masalan, float **matr;
Bunda haqiqiy sonlardan tashkil topgan matr nomli ikki o‘lchovli massiv e’lon qilinmoqda.
Massiv uzunligi new protsedurasi yordamida ikki bosqichda aniqlanishi lozim.
Masalan,
matr=new float *[m];
for (i=0; i

2. m x n o‘lchamli ikki o‘lchovli massivning 3-ustunini k soniga ko‘paytiring va o‘zgartirilgan massivni ekranga chiqarish dasturini tuzing.


Dasturi:
#include
#include
using namespace std;
int main ()
{
int i,j,m,n,k;
float **a;
cout<<"Qatorlar soni m="; cin>>m;
cout<<"Ustunlar soni n="; cin>>n;
a=new float *[m];
for (i=0; i cout<<"Massiv elementlarini kiriting:"< for (i=0; i for (j=0; j>a[i][j];
cout<<"ko'paytiriadigan son k="; cin>>k;
for (i=0; i for (i=0; i {
for (j=0; j cout<<" a["< cout< }
return 0;
}


Dastur natijasi:

8.5-rasm. Dastur natijasi
3. Ikki o‘lchovli a va b massivlar yig‘indisini topish dasturi tuzilsin.

#include


#include
using namespace std;
int main ()
{
int i,j,m,n;
float **a,**b,**c;
cout<<"Qatorlar soni m="; cin>>m;
cout<<"Ustunlar soni n="; cin>>n;
a=new float *[m];
for (i=0; i b=new float *[m];
for (i=0; i c=new float *[m];
for (i=0; i cout<<"a massiv elementlarini kiriting:"< for (i=0; i for (j=0; j>a[i][j];
cout<<"b massiv elementlarini kiriting:"< for (i=0; i for (j=0; j>b[i][j];
cout<<"a va b massivlar yig'indisi c massiv quyidagicha:"< for (i=0; i {
for (j=0; j cout<<" c["< cout< }
return 0;
}
Variant topshiriqlari


1-variant
1) 2)
3) o‘lchamli matritsaning t-qatoridagi eng katta elementni ekranga chiqaring.


2-variant
1) 2)
3) o‘lchamli matritsada eng kichik element va u turgan ustun nomerini ekranga chiqarib berish dasturini tuzing.


3-variant
1) 2)
3) o‘lchamli A va B matritsalar yigindisini topish dasturini tuzing.


4-variant
1) 2)
3) o‘lchamli matritsaning manfiy elementlari yigindisini ekranga chiqariing.
5-variant
1) 2)
3) o‘lchamli matritsani k soniga ko‘paytirish dasturini tuzing.


6-variant
1) 2)
3) o‘lchamli matritsaning t-ustunidagi eng katta elementni ekranga chiqaring.


7-variant
1) 2)
3) o‘lchamli matritsaning 3-qatorini k soniga ko‘paytirish dasturini tuzing.


8-variant
1) 2)
3) o‘lchamli matritsaning 2-ustunini k soniga ko‘paytiring.


9-variant
1) 2)
3) o‘lchamli matritsaning 2-qatorini k soniga ko‘paytirishdan hosil bo‘lgan bir o‘lchovli massivni ekranga chiqaring.


10-variant
1) 2)
3) o‘lchamli matritsaning t-qatoridagi eng katta elementni ekranga chiqaring.


11-variant
1) 2)
3) o‘lchamli matritsaning eng katta va eng kichik elementlari o‘rinlarini almashtirish dasturini tuzing.


12-variant
1) 2)
3) o‘lchamli matritsaning k-ustuni elementlari ko‘paytmasini ekranga chiqarish dasturini tuzing.


13-variant
1) 2)
3) o‘lchamli matritsaning musbat elementlari yig’indisini ekranga chiqarib berish dasturini tuzing.


14-variant
1) 2)
3) o‘lchamli matritsaning t-qatori elementlari yig’indisini ekranga chiqaring.


15-variant
1) 2)
3) o‘lchamli matritsaning eng katta elementi turgan qatorni ekranga chiqarib berish dasturini tuzing.

Download 173.17 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5




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