Navbat eng katta elementi topilsin va undan keyin 0 joylashtirilsin.
#include
#include using namespace std;
int main(){
int n,max1 = INT_MIN; cin>>n;
queuea,b;
int maxi;
for (int i=1; i<=n; i++){
int k; cin>>k;
a.push(k);
max1 = max(max1,k);
if (max1 == k)
maxi = i;
}
int d=1;
while (!a.empty()){
if (d==maxi){
cout<cout<<"0 ";
}
else {
cout<}
a.pop();
d++;
}
}
2. Navbat birinchi elementiga teng elementlari o’chirilsin.
#include using namespace std;
int main()
{
queue q;
queue q2;
int n,k;
cout <<"n= ";cin>>n;
for(int i=0;i{
cin>>k;
q.push(k); }
int a=q.front();
while(!q.empty())
{
int b=q.front();
if(b!=a)
{
q2.push(b); }
q.pop(); }
while(!q2.empty())
{
cout<q2.pop(); }}