7. n ta elementdan tashkil topgan navbat berilgan
Download 25.9 Kb.
|
mta3
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI RvaMA fakulteti 830-22 guruh talabasi Eshqobilov Xushnudning Ma’lumotlar Tuzilmasi va Algoritmlar fanidan 3-AMALIY ISHI Bajardi:Eshqobilov Xushnud Tekshirdi:Shoraimov Husanboy TOSHKENT 2023 7.N ta elementdan tashkil topgan navbat berilgan.navbatning eng katta elementini o’chiring #include #include int main() { std::queue int n; std::cout << "Queue elementlar sonini kiriting: "; std::cin >> n; std::cout << "Queue elementlarini kiriting: "; for(int i = 0; i < n; i++) { int element; std::cin >> element; myQueue.push(element); } int maxElement=myQueue.front(); int queueSize = myQueue.size(); for(int i = 0; i < queueSize; i++) { int frontElement = myQueue.front(); myQueue.pop(); if(frontElement > maxElement) { maxElement = frontElement; } myQueue.push(frontElement); } for(int i = 0; i < queueSize; i++) { int frontElement = myQueue.front(); if(frontElement != maxElement) { myQueue.push(frontElement); myQueue.pop(); } } std::cout << "Eng katta elementni o'chirgandan so'ng o'zgartirilgan navbat: "; while(!myQueue.empty()) { std::cout << myQueue.front() << " "; myQueue.pop(); } return 0; } Download 25.9 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling