Guruh talabasi Omonbayev Jaloliddin


Download 26.83 Kb.
Sana02.01.2023
Hajmi26.83 Kb.
#1075671
Bog'liq
7. Chiziqsiz MT


911-21 guruh talabasi Omonbayev Jaloliddin

Mavzu : Chiziqsiz MT.




  1. 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(); }}

Download 26.83 Kb.

Do'stlaringiz bilan baham:




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