0. Berilgan char turidagi to’plamning kata harflaridan 2- to’plamni, kichik elementidan 3- to’plamni hosil qiluvchi va ularni ekranga chiqaruvchi dastur tuzing



Yüklə 143,25 Kb.
tarix26.05.2022
ölçüsü143,25 Kb.
#59664
DASTURLASH 3-topsh


O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNALOGIYALARI VA KOMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI.

MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT. AXBOROT TEXNOLOGIYALARI UNIVERSITETI.


DASTURLASH 2 fani bo’yicha.
3-labarato’riya ishi.
BAJARDI:Xamzaqulov.B
TEKSHIRDI:Rustamova.M
Toshkent 2022
30.1) Berilgan char turidagi to’plamning kata harflaridan 2- to’plamni, kichik
elementidan 3- to’plamni hosil qiluvchi va ularni ekranga chiqaruvchi dastur
tuzing.

#include


#include
#include

using namespace std ;


int main()
{
set s1{'B', 'M', 'a', 'C', 't', 'O', 'q'};
set s2 ;
set s3 ;
cout << "s1 to'plami elementlari : " ;
for(auto i : s1)
{
cout << i << " " ;
}
cout << endl ;
for(auto i : s1)
{
if (i>=65&&i<=90)
{
s2.insert(i) ;
}
if (i>=97&&i<=122)
{
s3.insert(i) ;
}
}
cout << "s2 to'plami elementlari : " ;
for(auto i : s2)
{
cout << i << " " ;
}
cout << endl ;
cout << "s3 to'plami elementlari : " ;
for(auto i : s3)
{
cout << i << " " ;
}
cout << endl;
return 0 ;
}



30.2) Berilgan to’plam juft o’rindagi elementlaridan 2- to’plam hosil qilinsin, birinchi to’plamning juft o’rindagi elementlari o’chirilsin. Hamda ikkito’plam elementlari ekranga chop etilsin.

#include


#include
#include

using namespace std ;


int main()
{
// empty map container
map gquiz1;
// insert elements in random order
gquiz1.insert(pair(1, 40));
gquiz1.insert(pair(2, 30));
gquiz1.insert(pair(3, 60));
gquiz1.insert(pair(4, 20));
gquiz1.insert(pair(5, 50));
gquiz1.insert(pair(6, 50));
gquiz1.insert(pair(7, 10));
map::iterator itr;
cout << "\ngquiz 1 map : \n" ;
cout << "\tKalit\telement\n" ;
for (itr = gquiz1.begin(); itr != gquiz1.end(); itr++)
{
cout << '\t' << itr->first << '\t' << itr->second << '\n';
}
cout << endl;

map gquiz2(gquiz1.begin(), gquiz1.end());


// print all elements of the map gquiz2
/*cout << "\ngquiz2 map iga" << " gquiz1 mapi qo'shilganidan so'ng : \n";
cout << "\tKalit\telement\n";
for (itr = gquiz2.begin(); itr != gquiz2.end(); ++itr)
{
cout << '\t' << itr->first << '\t' << itr->second << '\n';
}
cout << endl;*/
for (int i = 2; i < gquiz1.size(); i+=2)
{
gquiz1.erase(gquiz1.find(i)) ;
}
cout << "\ngquiz1 map idan" << " juft o'rindagi elementlar uchirilgandan so'ng : \n";
cout << "\tKalit\telement\n";
for (itr = gquiz1.begin(); itr != gquiz1.end(); ++itr)
{
cout << '\t' << itr->first << '\t' << itr->second << '\n';
}
cout << endl;
for (int i = 1; i < gquiz1.size(); i+=2)
{
gquiz2.erase(gquiz2.find(i)) ;
}
cout << "\ngquiz 2 map : \n" ;
cout << "\tKalit\telement\n" ;
for (itr = gquiz2.begin(); itr != gquiz2.end(); itr++)
{
cout << '\t' << itr->first << '\t' << itr->second << '\n';
}
cout << endl;
cout << "Dastur tugadi!!!\n" ;
return 0 ;
}



Yüklə 143,25 Kb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin