Dasturlash 5-labaratoriya ishi. 512-21 gruh talabasi Mahmudov Asadbek



Yüklə 116,18 Kb.
tarix29.04.2022
ölçüsü116,18 Kb.
#115596
mahmudov asadbek dasturlash 5
SATTOROV FAZLIDDIN, filosofiya1, 2703пдф

Dasturlash 5-labaratoriya ishi.

512-21 gruh talabasi Mahmudov Asadbek

1.

Kitob va daftar class larinin Yarating va ularni bog’lovchi funksiyani yarating


#include

using namespace std;

class kitob{

public:


string name;

string author;

int page_num;

int year;

};

class Notebook{



public:

string color;

int page_num;

};

int main()



{

kitob MyBook;

Notebook MyNotebook;

MyNotebook.color="qora";

MyNotebook.page_num=36;

MyBook.name="phyton qollanma";

MyBook.author="Makhmudov Asadbek";

MyBook.page_num=120;

MyBook.year=2022;

cout<<"kitob nomi:"<

cout<<"kitob muallifi:"<

cout<<"nashr etilgan yil:"<

cout<<"sahifalar soni:"<

cout<<" "<

cout<<"daftarni rangi:"<

cout<<"daftarning sahifalar soni:"<

return 0;

}


2.

Oquv xonasi nomli sinf yarating.

Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi , qayta ishlovchi usullarni yarating.
#include

using namespace std;

class MyClassroom{

public:


string name;

string raqami;

string teacher;

string i;

string k;

string savol;

};

int main()



{

MyClassroom Myroom;

resin:

cout<<"xonaning nomi:";cin>>Myroom.name;

cout<<"xonaning raqami:";cin>>Myroom.raqami;

cout<<"xonaning oqituvchisi:";cin>>Myroom.teacher;

cout<<"xonaning interneti bormi ?"<<" ";cin>>Myroom.i;

cout<<"xonaning kompyuteri bormi ?"<<" ";cin>>Myroom.k;

cout<<" "<

cout<<"xonaning nomi-"<

cout<<"xonaning raqami-"<

cout<<"xonaning oqituvchisi-"<

cout<<"internet-"<

cout<<"kompyuter-"<

cout<<"qayta kiritasiz?";cin>>Myroom.savol;

if(Myroom.savol=="ha")

goto resin;

else


return 0;

}

3.

Nuqta nomlin sinf yaratilsin.Kamidaikkita sinf konstruktri yaratilsin.



Birinchi sinf konturi ikki nuqta orasida gi masofani topilsin

2- konsturuktordauchburchak yuzi topilsin.


#include

#include

using namespace std;

class Nuqta

{

private:



int d,c,e,b;

int q,w;

public:

Nuqta()


{

cout<<"dasturni boshlash"<

}

Nuqta(int y,int z,int x,int k,int g,int m)



{

g=q;


m=w;

d=x;


b=y;

c=z;


e=k;

}

float Masofa(int c,int b,int d,int e)



{float s;

s=sqrt(pow(c-b,2)+pow(d-e,2));

return s;

}

float Yuzasi(int g,int m){



float v;

v=(g*m)/2;

return v;

}

~Nuqta(){



cout<<"dasturni tugatish";

}

};



int main()

{

float x,y,z,q,w,k;



cout<<"1-tomoni kiriting :";

cin>>q;


cout<<"2-tomoni kiriting :";

cin>>w;


cout<<"1-nuqtani kiriting :";

cin>>x;


cout<<"2-nuqtani kiriting :";

cin>>y;


cout<<"3-nuqtani kiriting :";

cin>>z;


cout<<"4-nuqtani kiriting :";

cin>>k;


Nuqta obl;

cout<<"uchburchak yuzasi="<

cout<<"va"<

cout<<"2 nuqta orasidagi masofa="<

4.Birnecha xil yengil avtomobillar nomi,markalari va ularning narxlari berilgan.

Ulardan narxi 60 mln va 80 mln orasidagi narxlardan eng qimmatini aniqlovchi dastur tuzing.

#include

#include

using namespace std;

const int n=3;

class Avtomobil{

private: string nomi;

string markasi;

float narxi;

public:friend float qidirMaxNarx(Avtomobil k[]);

void setNarxi(float Narxi)

{

narxi=Narxi;



}

float getNarxi()

{

return narxi;



}

void setNomi(string Nomi){

nomi=Nomi;

}

string getNomi()



{return nomi;

}

void setMarkasi(string Markasi)



{markasi=Markasi;

}

string getMarkasi()



{return markasi;

}};


float qidirMaxNarx(Avtomobil k[])

{

cout<<"max narxli avtomobil:";



int max=k[0].narxi;

for(int i=0;i

{if(k[i].narxi>max)

max=k[i].narxi;

}

return max;



}

int main()

{

Avtomobil k[n];



string nomi;

string markasi;

int narxi;

for(int i=0;i

{cout<<"avtomobil nomini kiriting:";

cin>>nomi;

cout<<"avtomobil narxini kiriting:";

cin>>narxi;

cout<<"avtomobil markasini kiriting:";

cin>>markasi;

k[i].setNomi(nomi);

k[i].setNarxi(narxi);

k[i].setMarkasi(markasi);

}

cout<

}


Yüklə 116,18 Kb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©muhaz.org 2022
rəhbərliyinə müraciət

    Ana səhifə