|
F anidan tayyorlagan
|
bet | 4/4 | Sana | 21.12.2023 | Hajmi | 12,4 Kb. | | #125610 |
Bog'liq Dasturlash 2” f anidan tayyorlagan-fayllar.org
deque ikki tarafli tartib
set tolishi shart emas toyxat
Bunda har bir kalit bitta qiymat bilan bogproq qiymatlar
bogrindagi tartib
Sinf a dynamik doimiy massiv;
deque - ikki tomonlama navbat;
forward_list - bog'langan ro'yxat;
list rtasiga '+' belgi joylashtirilsin.
#include
#include
using namespace std;
int main()
{
// Empty Queue
queue myqueue;
myqueue.push(3);
myqueue.push(5);
myqueue.push(7);
myqueue.push(60);
myqueue.push(66);
myqueue.push(81);
// Printing content of queue
while (!myqueue.empty()) {
cout << '+' << myqueue.front();
myqueue.pop();
}
}
2-topshiriq
Royxatni juft sonlarini chiqaradigan dastur tuzing
#include
#include
using namespace std;
void view(stack my)
{
while(!my.empty())
{
cout<
my.pop();
}
}
int main() {
stack my,my1;
int n,x;
cout<<"Satckni o'lchamini kiriting: "; cin>>n;
for(int i=1; i<=n; i++)
{
cin>>x;
my.push(x);
}
cout<<"Hosil bo'lgan stack\n";
view(my);
for(int i=1; i<=n; i++)
{
x=my.top();
if(i%2==1)
my1.push(x);
my.pop();
}
cout<<"\nJut elemtlari olingan steck: \n";
view(my1);
}
4-topshiriq
Navbat ochirib tashlansin. Agar navbat elementlari soni toq bochirilsin.
#include
#include
using namespace std;
int main()
{
int n;
cin>>n;
int k;
vector v1;
for(int i=0; i
{
cin>>k;
v1.push_back(k);
}
int a,b;
if(n%2==0)
{
a=n/2;
b=a+1;
for(int i=0; i
{
if(i!=(a-1) && i!=(b-1))
{
cout<
}
}
}
else
{
a=n/2;
for(int i=0; i
{
if(i!=a)
{
cout<
}
}
}
return 0;
}
http://fayllar.org
|
| |