Mmuhammad Al-Xorazmiy nomidagi Toshkent axborot texnologiyalari unversitetining
Download 29.68 Kb.
|
dsd
MMuhammad Al-Xorazmiy nomidagi Toshkent axborot texnologiyalari unversitetining Kompyuter injinering fakuteti 1-kurs 211-22 guruh talabasi Mirzaaliyev Shohjahonning Dasturlash2 fanidan amaliy ishi. Toshkent 2022 Tekshirdi: Shokirov Shodmon Shoyimovich Bajardi : Mirzaaliyev Shohjahon 1-Amaliy ish 1. Yaratilgan sinf maydonlari orasida qidirish, saralash hamda kiritish chiqarish metodlari ishlab chiqilsin. 2. Yaratilgan sinf inkapsulyatsiya, merosxo’rlik, polimorfizm tushuncha va metodlarini qamrab olsin. Masala berilishi: Kod yozilishi: #include #include #include using namespace std; namespace YANGI_FAZA{ class shahar { public: char name[30]; int aholi; char made_data[20]; void input() { cout << "Shahar nomi:"; cin >> name; cout << "Qachon " << name << " nomini olgan: "; cin >> made_data; cout << "Shahar aholisi (mln):"; cin >> aholi; } void show() { cout << "Bizda mavjud bo'lgan barcha shaharlar:" << endl; } }; class mshahar: public shahar{ public: void show() { cout << setw(40) << name << "\t" << setw(25) << made_data << setw(15) << aholi << setw(15) << endl; } }; void search(mshahar c[], int count, char name[]) { bool check=false; for(int i = 0; i < count; i++) { if(strcmp(c[i].name, name)==0) { c[i].show(); check=true; } } if(check==false) cout << "Bizda " << name << " nomli shahar yoq\n"; } } using namespace YANGI_FAZA; int main() { shahar ob1; mshahar ob[100], temp; char name[30], names[30]; int count; cout << "Shahar sonini kiriting:"; cin >> count; for(int i=0; i ob[i].input();} cout << "Qidirilayotgan shahar nomini kiriting:"; cin >> name; system("cls"); cout << setw(40) << "Nomi" << "\t" << setw(25) << "Yili" << setw(15) << "Aholisi" << setw(15) << endl; search(ob, count, name); for(int i=0; i temp=ob[i]; ob[i]=ob[j]; ob[j]=temp; } } } cout << endl << endl; ob1.show(); cout << setw(40) << "Nomi" << "\t" << setw(25) << "Made data" << setw(15) << "Aholisi" << setw(15) << endl; for(int i=0; i < count; i++){ ob[i].show(); } return 0; } Download 29.68 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling