Dastur kodi #include


Download 124.94 Kb.
Sana21.11.2023
Hajmi124.94 Kb.
#1792716
Bog'liq
jumayev firdavs

Jumayev firdavs 019


AMALIYOTY ISHI-4
Mavzu______________________________________________________________

VARIANT-11
11.N ta elementdan tashkil topgan navbat berilgan.navbatning eng katta elementini toping va ushbu elementdan keyin 3 sonini kiriting.

DASTUR KODI
#include
#include
using namespace std;
void print(queuenavbat)
{
queuetemp = navbat;
while(!temp.empty())
{
cout<< temp.front() << endl;
temp.pop();
}
}
int main()
{
queue navbat;
navbat.push(1);
navbat.push(2);
navbat.push(3);
navbat.push(7);
navbat.push(6);
navbat.push(5);
queue temp = navbat;
print(navbat);
int maxElement = 0;
while(!temp.empty())
{
if(maxElement < temp.front())
{
maxElement = temp.front();
}
temp.pop();
}
while(!navbat.empty())
{
temp.push(navbat.front());
if(maxElement == navbat.front())
{
temp.push(3);
}
navbat.pop();
}
cout<<"'3' elementi maksimal elementdan so'ng qo'shilga holat :"<
print(temp);
return 0;
}


NATIJA



Download 124.94 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling