|
Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari unvirsiteti telekommunikatsiyalar fakulteti
|
tarix | 29.12.2022 | ölçüsü | 352,64 Kb. | | #121883 |
|
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNVIRSITETI
TELEKOMMUNIKATSIYALAR FAKULTETI
DASTURLASH 1 fani
4-mustaqil amaliyot ishi
Bajardi: 413-22 guruh 1-bosqich talabasi
Sunnatullayev Abdulaziz
Tekshirdi: Ishniyazov Odil
TOSHKENT 2022
18-VARIANT
1-misol
Natija:
Kodi :
#include
using namespace std;
class Mashina{
private:
string name, brend;
int narxi, tezlik;
public:
Mashina(){};
Mashina(string name, string brend, int narxi, int tezlik){
this -> name = name;
this -> brend = brend;
this -> narxi = narxi;
this -> tezlik = tezlik;
}
friend void chiqarish(Mashina);
int narx(){
return this->narxi;
}
int tez(){
return this->tezlik;
}
};
void chiqarish(Mashina m){
cout<<"Nomi: "<}
class Motosikl{
private:
string name, brend;
int narxi, tezlik;
public:
Motosikl(){};
Motosikl(string name, string brend, int narxi, int tezlik){
this -> name = name;
this -> brend = brend;
this -> narxi = narxi;
this -> tezlik = tezlik;
}
friend void chiqarish(Motosikl);
int narx(){
return this->narxi;
}
int tez(){
return this->tezlik;
}
};
void chiqarish(Motosikl m){
cout<<"Nomi: "<}
int main(){
int n; cout<<"Mashinalar sonini kiriting: "; cin >>n;
Mashina *moshina = new Mashina[n];
Motosikl *motosikl = new Motosikl[n];
string name, brend;
int narxi, tezlik;
for(int i=0; i cout<> name>>brend>>narxi>>tezlik;
moshina[i] = Mashina(name,brend,narxi,tezlik);
cout<> name>>brend>>narxi>>tezlik;
motosikl[i] = Motosikl(name,brend,narxi,tezlik);
}
for(int i=0; i if(moshina[i].narx()>motosikl[i].narx()){
cout<<"Ushbu mashina motosikldan qimmatroq: ";
chiqarish(moshina[i]);
}
else if(moshina[i].narx() cout<<"Ushbu mashina motosikldan arzonroq: ";
chiqarish(motosikl[i]);
}
else{
cout<<"Mashina va Motosikl bir xil narxda";
chiqarish(motosikl[i]); chiqarish(moshina[i]);
}
}
for(int i=0; i if(moshina[i].tez()>motosikl[i].tez()){
cout<<"Ushbu mashina motosikldan tezroq: ";
chiqarish(moshina[i]);
}
else if(moshina[i].tez() cout<<"Ushbu mashina motosikldan sekinroq: ";
chiqarish(motosikl[i]);
}
else{
cout<<"Mashina va Motosikl bir xil tezlikda";
chiqarish(motosikl[i]); chiqarish(moshina[i]);
}
}
}
2-misol
Natija:
#include
#include
using namespace std;
class Tortburchak{
private :
float tomon1, tomon2, perimetr, yuzasi, dioganal;
public :
Tortburchak(){};
Tortburchak(float tomon1, float tomon2){
this ->dioganal = sqrt(tomon1*tomon1+tomon2*tomon2);
this ->tomon1 = tomon1;
this ->tomon2 = tomon2;
this ->perimetr = 2*(tomon1+tomon2);
this ->yuzasi = tomon1*tomon2;
}
void chiqarish(){
cout<<"Tortburchak tomonlar:"< }
void qaytakiritish(){
cout<<"Yangi tomonlar: "; cin>>tomon1>>tomon2;
perimetr = 2*(tomon1+tomon2);
yuzasi = tomon1*tomon2;
dioganal = sqrt(tomon1*tomon1+tomon2*tomon2);
}
};
int main(){
cout<<"Tortburchaklar sonini kiriting: ";
int n; cin>>n;
float tomon1, tomon2, perimetr, yuzasi, dioganal;
Tortburchak *tortburchak = new Tortburchak[n];
for(int i=0; i cout< cin>>tomon1>>tomon2;
tortburchak[i]=Tortburchak(tomon1, tomon2);
}
for(int i=0; i tortburchak[i].chiqarish();
}
cout<<"Tomonlarni qayta kiritamiz: "< for(int i=0; i tortburchak[i].qaytakiritish();
}
cout<<"Yangi qiymatlar: "< for(int i=0; i tortburchak[i].chiqarish();
}
}
Dostları ilə paylaş: |
|
|