# G’ulomov Ahmadali Tekshirdi: Abdurahmonov Abbos variant

Bog'liq
Dasturlash 2
xudo xoxlasa tushadi99%, 3-labarotoriya ishi Saralash usul va algoritmlarini tadqiq qilis, cmd buyruqlari, Incremental model nima, 1matematik, word sAM 1 savol, Документ Microsoft Word (4), Ma\'ruzalar (2), ЛАБОРАТОРНАЯ РАБОТА N1, Ariza, Qalandarova Gulshoda, 1648631455, 1650692784, 1651669892 (2)
 Muhammad al-Xorazmiy nomidagi Toshkent axborot texnologiyalari universiteti DIF 311-21(012-L1) guruhi talabasi G’ulomov Ahmadalining dasturlash fanidan bajargan 2-mustaqil ishi. Bajardi: G’ulomov Ahmadali Tekshirdi: Abdurahmonov Abbos variant VECTOR hosil qiling elementlarini kamayish tartibida saralang Berilgan so‘zning unli harflarini NAVBAT ning chap tomonidan, undoshlarini o‘ng tomondan kiriting. Yechim: 1. #include #include using namespace std; //VECTOR hosil qiling elementlarini kamayish tartibida saralang int main() { vector vectorNum; cout << "Nechta son kiritmoqchisiz?"; int numberOfNumbers; cin >> numberOfNumbers; int number; for (int i = 0; i < numberOfNumbers; ++i) { cin >> number; vectorNum.push_back(number); } for (int i = 0; i < vectorNum.size(); ++i) { for (int j = 0; j < vectorNum.size() - 1; ++j) { if (vectorNum.at(j) < vectorNum.at(j + 1)) { swap(vectorNum.at(j), vectorNum.at(j + 1)); } } } for (auto &item: vectorNum) { cout << item; cout << " "; } return 0; 2. Bu masalani Navbat ya’ni queue orqali va list orqali yechamiz,masalaning yechimini tog’riligini listda ko’ra olishimiz mumkin.Chunki queue ga element kiritganimizda bu elementlar kiritsh tartibidi saqlanmaydi. #include #include #include #include using namespace std; class helperCharList { list helperList; public: bool contains(char ch) { for (const auto &item: helperList) { if (item == ch)return true; } return false; } void push(char ch) { helperList.push_back(ch); } }; int main() { priority_queue queueChars; cout << "So'zning uzunligini kiriting:"; int length; cin >> length; char str[length]; cout << "So'zni kiriting:"; cin >> str; helperCharList unliTovushlar; unliTovushlar.push('a'); unliTovushlar.push('i'); unliTovushlar.push('e'); unliTovushlar.push('u'); unliTovushlar.push('o'); unliTovushlar.push('A'); unliTovushlar.push('I'); unliTovushlar.push('E'); unliTovushlar.push('U'); unliTovushlar.push('O'); cout << "Unli tovushlar:" << endl; for (int i = 0; i < sizeof(str); ++i) { if (unliTovushlar.contains(str[i])) { queueChars.push(str[i]); cout << str[i] << endl; } } cout << "Undosh tovushlar:" << endl; for (int i = 0; i < sizeof(str); ++i) { if (!unliTovushlar.contains(str[i])) { queueChars.push(str[i]); cout << str[i] << endl; } } while (!queueChars.empty()) { cout << queueChars.top(); queueChars.pop(); } return 0; } ========================================== Endi list orqali yechib ko’rsatamiz: #include #include #include #include #include using namespace std; //Berilgan so‘zning unli harflarini NAVBAT ning chap tomonidan, undoshlarini o‘ng tomondan kiriting. int main() { list chars; string str; cout << "So'zni kiriting:"; cin >> str; for (const auto item: str) { if (item == 'a' item == 'e' item == 'o' item == 'i' item == 'u' item == 'A' item == 'E' item == 'O' item == 'U' || item == 'I') { chars.push_front(item); } else { chars.push_back(item); } } list helper = chars; for (const auto &item: chars){ cout< cout<<" "; } cout << '\n'; } Download 0.68 Mb.