Muxammad Al Xorazimiy Nomidagi Toshkent Axborot Texnalogiyalari Unversiteti
Download 137.49 Kb.
|
dasturlash 5 (1)
- Bu sahifa navigatsiya:
- Labaratoriya ishi
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 for(int i=0;i<10;i++){ int rand = random()%50+1; cout<<" "< } cout< 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 srand(time_t(NULL)); for(int i=0;i<10;i++){ int rand = random()%50+1; int rand1 = random()%10+1; // cout<<" "< } map 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 srand(time_t(NULL)); for(int i=0;i<10;i++){ int rand = random()%50+1; int rand1 = random()%10+1; // cout<<" "< } map 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
ma'muriyatiga murojaat qiling