Muxammad Al Xorazimiy Nomidagi Toshkent Axborot Texnalogiyalari Unversiteti


Download 137.49 Kb.
Sana16.06.2023
Hajmi137.49 Kb.
#1492195
Bog'liq
dasturlash 5 (1)


O`ZBEKISTON RESPUBLIKASI AXBOROT TEXMALOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI MUXAMMAD AL-XORAZIMIY NOMIDAGI AXBOROT TEXNALOGIYALARI UNIVERSITETI



Muxammad Al_Xorazimiy Nomidagi Toshkent Axborot Texnalogiyalari Unversiteti
Talabasi Aliqulov Azizjonning Dasturlash fanidan.


Labaratoriya ishi


Toshkent – 2022

3 a) Yangi konteynerlar hosil qiling, uni standart funksiyalar yordamida elementlar bilan to’lating count funksiyasi yordamida amallar bajaring;


// birinchi 1-topshiriq
#include
using namespace std;
int main(){
srand(time_t(NULL));
set myset;
for(int i=0;i<10;i++){
int rand = random()%50+1;
cout<<" "<myset.insert(rand);
}
cout<set ::iterator it = myset.begin();
for(it= myset.begin();it!=myset.end();it++)
{
cout<< *it<<" ";
}
int kirit;
cout<<"\nSon kiriting bu sonni bor yo'q ligini qaytaramiz";
cin>>kirit;
if(myset.count(kirit)){
cout<<"siz kirititgan son mavjud";
}
else cout<<"bu son mavjud emas";
}

b) Iteratorlardan foydalanib map konteyneri ustida amallar bajaring;


#include
using namespace std;
int main()
{
// initialize container
map mymap;
srand(time_t(NULL));
for(int i=0;i<10;i++){
int rand = random()%50+1;
int rand1 = random()%10+1;
// cout<<" "<mymap.insert({rand1,rand});
}
map::iterator itr;
cout << "\nThe map gquiz1 is : \n";
cout << "\tfirst\tsecond\n";
for (itr = mymap.begin(); itr != mymap.end(); ++itr) {
cout << '\t' << itr->first << '\t' << itr->second
<< '\n';
}
int kirit,shart=0;

cout <<"qidiralayotgan keyni kiritng "; cin>>kirit;


for (itr = mymap.begin(); itr != mymap.end(); ++itr) {

if(kirit == itr->first){


cout << '\t' << itr->first << '\t' << itr->second<< '\n';
shart = 1;
}
}
if(shart ==0){
cout<<"BUnaqa elemt yuq";
}
return 0;
}

C) free () funksiyasidan foydalanib xotirani dinamik taqsimlashni amalga oshiring


#include
using namespace std;
int main()
{
// initialize container
map mymap;
srand(time_t(NULL));
for(int i=0;i<10;i++){
int rand = random()%50+1;
int rand1 = random()%10+1;
// cout<<" "<mymap.insert({rand1,rand});
}
map::iterator itr;
cout << "\nThe map gquiz1 is : \n";
cout << "\tfirst\tsecond\n";
for (itr = mymap.begin(); itr != mymap.end(); ++itr) {
cout << '\t' << itr->first << '\t' << itr->second
<< '\n';
}
int kirit,shart=0;

cout <<"qidiralayotgan keyni kiritng "; cin>>kirit;


for (itr = mymap.begin(); itr != mymap.end(); ++itr) {

if(kirit == itr->first){


cout << '\t' << itr->first << '\t' << itr->second<< '\n';
shart = 1;
}
}
if(shart ==0){
cout<<"BUnaqa elemt yuq";
}
return 0;
}

Download 137.49 Kb.

Do'stlaringiz bilan baham:




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