IV-LABORATORIYA ISHI
№8 variant
Topshiriq 1.
8
Navbatda birinchi elementga teng barcha
elementlar o’chirilsin
Dastur ko’di:
#include
#include
#include;
using namespace std;
int main()
{
queue q;
queue q2;
int n, x;
cout<<"STACK ELEMENTLARI SONINI KIRITING"<
cout<<"n="; cin>>n;
cout<<"=====================================
=============================="<
cout<<"ELEMENTLARNI KIRITISH: (x ga qiymat berib
enter tugmasini bosing....) " <
for(int i=0; i
{
cout<<"x="; cin >>x;
q.push(x);
}
const int& m = q.front();
while(!q.empty())
{
if(q.front() != m)
{
q2.push(q.front());
}
q.pop();
}
n = q2.size();
for(int i=0; i
{
q.push(q2.front());
q2.pop();
}
cout<<"=====================================
============================"<
cout<<"Navbatda birinchi elementga teng bolgan
barcha sonlar o'chirildi"<
for(int i=0; i
{
cout << q.front() << endl;
q.pop();
}
system("pause");
return 0;
}