Class Talaba {
Download 14.52 Kb.
|
13.TALABA sinfi yaratilsin. Unda ixtiyoriy talaba haqida qandaydir alomatlar boyicha talabani izlash(familiya, tugilgan yili yoki telefon nomeri boyicha), yangi malumotni qoshish, ochirish va tartiblash imkoniyatlari bo`lsin.c++ dasturlash tilida #include #include #include class Talaba { public: std::string ism; std::string familiya; Talaba(std::string ism, std::string familiya) { this->ism = ism; this->familiya = familiya; } std::string getTalabaInfo() { return ism + " " + familiya; } }; int main() { std::vector int tanlash; while (true) { std::cout << "1. Yangi talaba qo'shish\n" << "2. Talabalarni ko'rish\n" << "3. Talabalarni o'chirish\n" << "4. Tartiblash\n" << "0. Dasturdan chiqish\n" << "Tanlang: "; std::cin >> tanlash; if (tanlash == 1) { std::string ism, familiya; std::cout << "Ism: "; std::cin >> ism; std::cout << "Familiya: "; std::cin >> familiya; Talaba talaba(ism, familiya); talabalar.push_back(talaba); std::cout << "Talaba muvaffaqiyatli qo'shildi!\n"; } else if (tanlash == 2) { std::cout << "Talabalar ro'yxati:\n"; for (int i = 0; i < talabalar.size(); i++) { std::cout << i + 1 << ". " << talabalar[i].getTalabaInfo() << "\n"; } } else if (tanlash == 3) { int tartib; std::cout << "O'chirish uchun tartib raqamini kiriting: "; std::cin >> tartib; if (tartib > 0 && tartib <= talabalar.size()) { talabalar.erase(talabalar.begin() + tartib - 1); std::cout << "Talaba o'chirildi!\n"; } else { std::cout << "Noto'g'ri tartib raqami kiritildi!\n"; } } else if (tanlash == 4) { std::cout << "Talabalarni tartiblash:\n"; for (int i = 0; i < talabalar.size() - 1; i++) { for (int j = 0; j < talabalar.size() - i - 1; j++) { if (talabalar[j].ism > talabalar[j + 1].ism) { Talaba temp = talabalar[j]; talabalar[j] = talabalar[j + 1]; talabalar[j + 1] = temp; } } } std::cout << "Talabalar muvaffaqiyatli tartiblandi!\n"; } else if(tanlash == 0) { break; } else { std::cout << "Noto'g'ri tanlov! Qaytadan urinib ko'ring.\n"; } } return 0; } Download 14.52 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling