Dasturiy injenering fakulteti 12 20 : Raximov Umidjon chi lab ishi


Download 11.46 Kb.
Sana02.01.2022
Hajmi11.46 Kb.
#199365
Bog'liq
Dasturiy injene-WPS Office


Dasturiy injenering fakulteti 312_20 :Raximov Umidjon 9 chi lab ishi.

1.10. Nuqta nomli sinf yaratilsin. Kamida ikkita sinf konstruktori yaratilsin. Birinchi sinf kontruktori ikki nuqta orasidagi masafani topilsin. Ikkinchi konstruktorida uchburchak yuzi topilsin.

#include

#include

using namespace std;

class Nuqta {
public:

int x1,y1;

int x2,y2;

Nuqta() {

cout << "Nuqtalarni kiriting: " << endl;

}

void print() {



float m;

cout << "Birinchi nuqta: (" << x1 << "," << y1 << ")" << endl;

cout << "Ikkinchi nuqta: (" << x2 << "," << y2 << ")" << endl;

m = sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2));

cout << "Ikki nuqta orasidagi masofa: " << m;

}

};



int main() {
Nuqta k;

cout << "x1="; cin >> k.x1;

cout << "y1="; cin >> k.y1;

cout << "x2="; cin >> k.x2;

cout << "y2="; cin >> k.y2;

k.print();


return 0;

}

2.4. Firmaning xodimi xaqida quyidagi ma’lumotlar mavjud: familiyasi, ismi, yoshi, xarbiy xizmatga layoqatligi. Shu ma’lumotlarga asoslanib, xarbiy xizmatga layoqatli eng yosh xodimning familiyasini aniqlash dasturini tuzing.



####################################################################

#include


using namespace std;
class Firmaning_xodimlari {

public:


friend void print(Firmaning_xodimlari h);

char familiyasi[30];

char ismi[30];

int yoshi;

char jinsi[10];

char xarbiy_xizmatga_layoqatligi[20];

};

void print(Firmaning_xodimlari h) {



if ((h.xarbiy_xizmatga_layoqatligi == "Layoqatli") && (h.yoshi<22)) {

cout << h.familiyasi << " " << h.ismi;

}

}
int main() {



Firmaning_xodimlari k, l;

cout << "Xodim familiyasi: "; cin >> k.familiyasi;

cout << "Xodim ismi: "; cin >> k.ismi;

cout << "Xodim yoshi: "; cin >> k.yoshi;

cout << "Xarbiy xizmatga layoqatligi: "; cin >> k.xarbiy_xizmatga_layoqatligi;
cout << "Xodim familiyasi: "; cin >> l.familiyasi;

cout << "Xodim ismi: "; cin >> l.ismi;

cout << "Xodim yoshi: "; cin >> l.yoshi;

cout << "Xarbiy xizmatga layoqatligi: "; cin >> l.xarbiy_xizmatga_layoqatligi;

print(k);

print(l);


return 0;

}

3.14. Xokkeychi (ism, yosh, amplua, komanda)--ampula



#include
using namespace std;
class Xokkeychi {

public:


char Ism[30];

int Yosh;

char Amplua[30];

char Komanda[30];

friend void set(Xokkeychi k);

};

void set(Xokkeychi k) {



cout << k.Amplua << endl;

}

int main() {



Xokkeychi l, k, j;
cout << "Ism: "; cin >> l.Ism;

cout << "Yosh: "; cin >> l.Yosh;

cout << "Amplua: "; cin >> l.Amplua;

cout << "Komanda: "; cin >> l.Komanda;


cout << "Ism: "; cin >> k.Ism;

cout << "Yosh: "; cin >> k.Yosh;

cout << "Amplua: "; cin >> k.Amplua;

cout << "Komanda: "; cin >> k.Komanda;


cout << "Ism: "; cin >> j.Ism;

cout << "Yosh: "; cin >> j.Yosh;

cout << "Amplua: "; cin >> j.Amplua;

cout << "Komanda: "; cin >> j.Komanda;


set(k); set(l); set(j);

_getwch();

return 0;



}

Download 11.46 Kb.

Do'stlaringiz bilan baham:




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