Ro’yxatdagi eng kichik elementini toping


Download 319.03 Kb.
Sana30.04.2023
Hajmi319.03 Kb.
#1415566
Bog'liq
Mirzaabbos


Muhammad Al-Xorazmiy Nomidagi Toshkent Axborot Texnalogiyalari Universiteti

SWD 005-2 guruh talabasi Zaylobiddinov Mirzaabbosning Dasturlash II (amaliyot) fanidan tayyorlagan 2-amaliy ishi
Variant 31.

1.

Ro’yxatdagi eng kichik elementini toping.

C++ kodi:


#include
#include
using namespace std;
int main(){
list mylist;
int n,a;
cout<<"Nechta element kiritmoqchisiz: n=";cin>>n;
for(int i=0;icin>>a;
mylist.push_back(a);
}
int min=mylist.front();
for(auto i=mylist.begin();i!=mylist.end();i++){
if(min>*i){
min=*i;
}
}
cout<<"\nRo'yhatning eng kichik elementi: min="<}



2.

Deque barcha juft elementlari o’chirilsin.

C++ kodi:


#include
#include
using namespace std;
int main(){
dequemydeque={5,4,9,6,3,10,14,7,20,5,3};
cout<<"Dastlabki ro'yhat:\n";
for(auto i=mydeque.begin();i!=mydeque.end();i++){
cout<<*i<<" ";
}
for(auto i=mydeque.begin();i!=mydeque.end();i++){
if(*i%2==0){
mydeque.erase(i,i+1);
}
}
cout<<"\nO'zgartirilgan ro'yhat:\n";
for(auto i=mydeque.begin();i!=mydeque.end();i++){
cout<<*i<<" ";
}
}

Download 319.03 Kb.

Do'stlaringiz bilan baham:




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