talabalar;
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;
}