cin >> sports[i].sportType; cout << "Bu sport turi necha kishi bo'lib o'ynaladi:"; cin >> sports[i].numberOfPlayers; cout << "Bu sport turining asos solingan joyi:"; cin >> sports[i].establishedState; } }
void set(Sport sports[],int numberOfSports){ string nameOfSport; cout << "Qanday sport turini qidirmoqdasiz,kiriting:"; cin >> nameOfSport; for (int i = 0; i < numberOfSports; ++i) { if (sports[i].sportType == nameOfSport) { cout<<"Yangi sport turning nomini kiriting:"; cin>>sports[i].sportType; cout<<"Yangi sport turi necha kishi bo'lib o'ynaladi:"; cin>>sports[i].numberOfPlayers; cout<<"Yangi sport turi qayerda tashkil topgan:"; cin>>sports[i].establishedState; cout<<"Sport turi muvaqqiyatli o'zgartirildi"; return; } } cout << "Bunday sport turi yo'q!!!"; } void sorting(Sport sports[], int numberOfSports) { for (int i = 0; i < numberOfSports; ++i) { for (int j = 0; j < numberOfSports - 1; ++j) { if (sports[j].numberOfPlayers > sports[j + 1].numberOfPlayers) { swap(sports[j], sports[j + 1]); } } } }
void search(Sport sports[], int numberOfSports) { string nameOfSport; cout << "Qanday sport turini qidirmoqdasiz,kiriting:"; cin >> nameOfSport; for (int i = 0; i < numberOfSports; ++i) { if (sports[i].sportType == nameOfSport) { cout << "Siz qidirgan sport turi ma'lumotlari:" << endl; cout << "Sport turi:" << sports[i].sportType << endl; cout << "Sport turini nechi kishi bo'lib o'ynalishi:" << sports[i].numberOfPlayers << endl; cout << "Sport turiga asos solingan joy:" << sports[i].establishedState << endl; return; } } cout << "Bunday sport turi yo'q!!!"; }
void shows(Sport sports[], int numberOfSports) { for (int i = 0; i < numberOfSports; ++i) { cout << i + 1 << "-sport turi ma'lumotlari:" << endl; cout << "Sport turi:" << sports[i].sportType << endl; cout << "Sport turi nechi kishi bilan o'ynalishi:" << sports[i].numberOfPlayers << endl; cout << "Sport turiga qayerda asos solinganligi" << sports[i].establishedState << endl; } } }; } using namespace fazo;
int main() { int option = 1; Sport sports[200]; int numberOfSports; cout << "Tizimda nechta sport turi mavjud bo'lishini xohlaysiz?" << endl; cin >> numberOfSports; sports[200].start(sports, numberOfSports); helper: while (option != 0) { cout << "Bo'limni tanlang:" << endl; cout << "1-Qidirish" << endl; cout << "2-Saralash" << endl; cout << "3-O'zgartirish" << endl; cout << "4-Tizimdagi barcha sport turlarining ma'lumotlarini ko'rish" << endl; cout << "0-Tizimdan chiqish" << endl; cin >> option; switch (option) { case 1: sports[200].search(sports, numberOfSports); break; case 2: sports[200].sorting(sports, numberOfSports); break; case 3: sports[200].set(sports, numberOfSports); break; case 4: sports[200].shows(sports, numberOfSports); break; case 0: break; default: break;
}
}
return 0; } 1)Kodimizda qidirish funksiyasini search metodi bajaryapti; 2)Saralash funksiyasini sorting metodi amalga oshiryapti.Saralashni bublle sorting usuli orqali amalga oshiryapti; 3)O’zgartirish funksiyasini set metodi amalga oshiryapti 2)Natija: