Almurodov Lochinbekning dasturlashdan amaliy topshiriq ishlari


Download 74.82 Kb.
Sana11.05.2023
Hajmi74.82 Kb.
#1455062
Bog'liq
Almurodov Lochinbekning dasturlashdan amaliy topshiriq ishlari


Almurodov Lochinbekning dasturlashdan amaliy topshiriq ishlari
1.Ro'yxatdagi eng kichik elementini toping.
#include
#include
#include
#include
using namespace std;
int main(){
int n;
cout<<"Elementlar soni:";cin>>n;
vectorrandom;
srand(time(NULL));
for(int i=0;irandom.push_back(rand()%100+i);
}
int min=random.front();
for(int i=0;iif(random[i]}
for(int i=0;icout<}
cout<<"\nmin element:"<return 0;
}

1.Deque barcha juft elementlari o'chirilsin.
#include
using namespace std;

int main() {


deque d;
srand(time(NULL));
for (int i = 1; i <= 10; i++) {
d.push_back(rand() % 100+i);
}

cout << "Deque before removal of even elements: ";


for (auto x : d) {
cout << x << " ";
}
cout << endl;


// Even elements are removed
for (auto it = d.begin(); it != d.end(); ) {
if (*it % 2 == 0) {
it = d.erase(it);
} else {
++it;
}
}

cout << "Deque after removal of even elements: ";


for (auto x : d) {
cout << x << " ";
}
cout << endl;


return 0;
}



1.Tasodifiy n ta son bilan stekni to'ldiring va shu stekdagi musbat elementlar sonini toping.
#include
using namespace std;
int main(){
stackstack;
srand(time(NULL));
int n;
cin>>n;
int i1=-1;
for(int i=0; ii1*=-1;
stack.push(i1*rand()%100+i);
}
int count=0;
while(!stack.empty()){
cout<if(stack.top()>0){
count++;
}
stack.pop();
}
cout<<"\n"<}

Download 74.82 Kb.

Do'stlaringiz bilan baham:




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