talaba nomli nonlar fazosi
7. class Talaba{
8. private: //
modifikator
9. //
yopiq maydonlar
10. string familiyasi, ismi;
11. int kursi, baholari[7];
12. int stipendiyasi;
13. public:
14.//
sinfning yopiq maydonlariga kirish uchun doist funksiyalar
15.friend void Qidirish(talaba::Talaba t[], int n);
16.friend void Saralash(talaba::Talaba t[], int n);
17.friend void Kurs_ozgartirish(talaba::Talaba t[], int n);
18. void set(string F, string I, int K) {
19. familiyasi = F;
20. ismi = I;
21. kursi = K;}
22. void get() {
23.cout<<”Fam: ”<24.cout<<”Ismi: ”<25.cout<<”Yoshi: ”<26.void setBaholari(int baho_soni) {
27. srand(time(NULL));
28. for (int i = 0; i 29. baholari[i]=rand()%6+1;
30.}}
31. void setKursi() {
32.kursi++;}
33. void setStipendiyasi(int baho_soni) {
34. int minBaho=baholari[0];
35.for (int i = 0; i 36. if(minBaho>baholari [i]) minBaho=baholari[i];}
37. switch (minBaho){
38.case 3: stipendiyasi=270000; break;
39. case 4: stipendiyasi=400000; break;
40. case 5: stipendiyasi=550000; break;
41.default:stipendiyasi=0; }} };
42. void Qidirish(talaba::Talaba t[], int n) {
43. cout<<”Qidirilayotgan talaba ismini kiriting: ”<44. string s; cin>>s; bool bor=false;
45. for (int i = 0; i < n; i++) {
46. if(t[i].ismi.compare(s)==0) {bor=true;
47.t[i].get();} }
49.if(!bor) cout<<”Bu ismli talaba ro‘yhatda yo‘q!M<49.cout<50. void Saralash(talaba::Talaba t[], int n) {
51.cout<<”Familiya bo‘yicha saralangan holati: \n”;
52.talaba::Talaba temp;
53.for (int i = 0; i 54. for (int j = 0; j 55if(t[i].familiyasi.compare(t[j].familiyasi)<0) {
56.temp=t[i]; t[i]=t[j]; t[j]=temp; } }}
57. for (int i = 0; i 59t[i].get(); } cout<59. void Kurs_ozgartirish(talaba::Talaba t[], int n) {
60.cout<<”Kursdan kursga o‘tganligi haqida ma’lumot:\n”;
61. bool bitiruvchi=false;
62. for (int i = 0; i 63if(t[i].stipendiyasi!=0 && t[i].kursi==4)
64. bitiruvchi=true;
65if(t[i].stipendiyasi!=0 && t[i].kursi<4)
6 6 t[i].setKursi();
67.if(!bitiruvchi) t[i].get();
68.else{
69t[i].get();
70.cout<<” Siz bitiruvchisiz!!M<71.bitiruvchi = false; } } }
72. int main(){
73.string fam[]={MXoshimov", MSaidaliyevaM, MBaxodirovM,MNishonovM};
74.string ism[]={MDostonM, "Xurshida", MTemurM, MBotirM};
75.int yoshlari[]={18,19,20,21};
76.talaba::Talaba t[100];
77. for (int i = 0; i <4; i++) {
78. t[i].set(fam [i],ism [i],yoshlari [i]);
79.t[i].setBaholari(4);
80. t[i].setStipendiyasi(4); 81t[i].get(); }
82.cout<83. talaba::Qidirish(t,4);
84. talaba::Saralash(t,4);
85. talaba::Kurs_ozgartirish(t,4);
86.}
Dastur natijasi:
Fam: Xoshimov
Ismi: Doston
Yoshi: 18
Fam: Saidaliyeva
Ismi: Xurshida
Yoshi: 19
Fam: Baxodirov
Ismi: Temur
Yoshi: 20
Fam: Nishonov
Ismi: Botir
Yoshi: 21
Fam: Nishonov
Ismi: Botir
Yoshi: 21
Fam: Saidaliyeva
Ismi: Xurshida
Yoshi: 19
Fam: Xoshimov
Ismi: Doston
Yoshi: 18
Kursdan kursga o‘tganligi haqida
ma’lumot:
Fam: Baxodirov
Ismi: Temur
Yoshi: 20
Fam: Nishonov
Ismi: Botir
Yoshi: 21
Fam: Saidaliyeva
Ismi: Xurshida
Yoshi: 19
Fam: Xoshimov
Ismi: Doston
Yoshi: 18
Qidirilayotgan talaba ismini
kiriting:
Temur
Fam: Baxodirov
Ismi: Temur
Yoshi: 20
Familiya bo‘yicha saralangan
holati:
Fam: Baxodirov
Ismi: Temur
Yoshi: 20
|