4-amaliyot ishi mavzu: stack,queue,dequeue(stek,navbat,dek) 714-21 guruh talabasi Matyoqubov Yusufboy


Download 28.13 Kb.
Sana14.12.2022
Hajmi28.13 Kb.
#1006149
Bog'liq
Matyoqubov



4-AMALIYOT ISHI
MAVZU: STACK,QUEUE,DEQUEUE(STEK,NAVBAT,DEK)


714-21 guruh talabasi Matyoqubov Yusufboy.
11-VARIANT
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 show(queue q) {
queue q1 = q;
while (!q1.empty()) {
cout << '\t' << q1.front();
q1.pop();
}
cout << '\n';
}
int max(queue q) {
queue q1 = q;
int maxn = q1.front();
while (!q1.empty()) {
if(maxn < q1.front()) {
maxn = q1.front();
}
q1.pop();
}
return maxn;
}
queue task(queue q, int x) {
queue q1;
int maxn = max(q);
while (!q.empty()) {
q1.push(q.front());
if(q.front() == maxn) {
q1.push(x);
}
q.pop();
}
return q1;
}
int main() {
queue a;
a.push(10);
a.push(30);
a.push(20);
a.push(5);
cout << "a ning elemetlari : ";
show(a);
cout << endl;
queue b = task(a, 3);
cout << "b ning elemetlari : ";
show(b);
}

Download 28.13 Kb.

Do'stlaringiz bilan baham:




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