#include using namespace std


Download 0.52 Mb.
Sana24.12.2022
Hajmi0.52 Mb.
#1052080
Bog'liq
5-iw 2-variant



O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYA-LARI VA KOMMUNIKATSIYALARINI RIJOJLANTIRISH VAZIRLIGI MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

Dasturlash fani bo’yicha



Laboratoriya ishi-5

Bajardi: 1-kurs talabasi


Abdumo’minov O’tkir
Tekshirdi: Begulov O’tkir

2-variant


1)Savol:

Kod:
#include


#include
using namespace std;
class Shar {
private:
float pi = 3.1415, r, d = 2 * r, s = 0, v = 0;
string tur;
public:
Shar (float r, float d, float pi) {
this->r = r;
this->d = d;
this->pi = pi;
};
void setYP() {
this->s = (4*pi*r*r);
this->v = (4/3.*pi*r*r*r);
}
void getYP() {
cout << "Shar hajmi: " << v;
cout << " Shar yuzi: " << s << endl;
}
void set_tomon(float r, float d, float pi) {
this->r = r;
this->d = d;
this->pi = pi;
}
void get_tomon() {
cout << r << " " << d << " " << pi << endl;
}
};
int main() {
float r, d, pi;
cout << "Sharning parametrlarini kiriting(r, d, pi): "; cin >> r >> d >> pi;
Shar obj = Shar(r, d, pi);
obj.setYP();
obj.getYP();
cout << "Yangi qiymatlarni kiriting: "; cin >> r >> d >> pi;
obj.set_tomon(r, d, pi);
cout << "Yangi qiymatlar uchun: \n";
obj.get_tomon();
obj.setYP();
obj.getYP();
{
float r, d, pi;
cout << "Yana Sharning parametrlarini kiriting(r, d, pi): "; cin >> r >> d >> pi;
Shar obj = Shar(r, d, pi);
obj.setYP();
obj.getYP();
cout << "Yana Yangi qiymatlarni kiriting: "; cin >> r >> d >> pi;
obj.set_tomon(r, d, pi);
cout << "Yana Yangi qiymatlar uchun: \n";
obj.get_tomon();
obj.setYP();
obj.getYP();
}
}
Javob:

2)Savol:

Kod:
#include
using namespace std;
class Tovar{
private:
string nomi;
int miqdori,narxi, sana[3];

public:
void kirit(){
cin >> nomi >> miqdori >> narxi >> sana[0] >> sana[1] >> sana[2];
}
void chiqar(){
cout << "Nomi: " << nomi << " Miqdor(kg): " << miqdori << " Narxi: " << narxi << " Sanasi: " << sana[0] <<"." << sana[1] << "." << sana[2] << endl;
}
int narx(){
return narxi;
}
};
void qidir(Tovar *a,int n){
int k=0;
for(int i=0;i
if(a[i].narx()>10000){
a[i].chiqar(); k++;
}
}
if(k){
cout << "Berilgan shartdagi tovarlar soni: " << k;
}else{
cout << "Bunday tovarlar mavjud emas!";
}
}
int main(){
int n;
cin >> n;
Tovar *tovarlar = new Tovar[n];
for(int i=0;i
tovarlar[i].kirit();
}
qidir(tovarlar,n);
}
Javob:

ETIBORINDIZ UCHUN RAXMAT !!!




Download 0.52 Mb.

Do'stlaringiz bilan baham:




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