# Navbat eng kichik elementi topilsin va undan keyin 0 joylashtirilsin

 Sana 29.04.2022 Hajmi 229.36 Kb. #660777
Bog'liq
Nur Dasturlash 02
Absolyut yaqinlashuvchi qatorlar. 1-mustaqil ish, 2-kurs, mat analiz, 77777777, dorilarni saqlash va tarqatish, 1-mavzu., Nur Dasturlash 02, Fazlullo dasturlash 02, Kurs ishi mavzulari Destruktiv 114-19, О Т З Ы В, Obyektivka Raxmonov Firdavs, Yer osti suvlari, 1480062469 64677, Madan jinslarini namunalash1, 1-maruza matni, Yer po`stining geokimyosi
 28-variant Navbat eng kichik elementi topilsin va undan keyin 0 joylashtirilsin

Iskandarov Nurbek

#include

#include
using namespace std;
int main()
{
queue qu;
queue qu2;
int n;
cout << "Navbat elementlari sonini kiriting:";
cin >> n;
cout << "Navbat elementlarini kiriting:";
for (int i = 0, a; i < n; i++)
{
cin >> a;
qu.push(a);
qu2.push(a);
}
const int& k = qu2.front();
int min = k;
for (int i = 0; i < n; i++)
{
if (qu2.front() < min) min = qu2.front();
qu2.pop();
}
cout << "min=" << min << endl;
for (int i = 0; i < n; i++)
{
if (qu.front() == min)
{
qu2.push(qu.front());
qu2.push(0);
qu.pop();
continue;
}
qu2.push(qu.front());
qu.pop();
}
n = qu2.size();
for (int i = 0; i < n; i++)
{
cout << qu2.front() << " "; qu2.pop();
} }