Bajardi: xujaqulov ural tekshirdi: fayzullaeva zarnigor
Sana 16.06.2022 Hajmi 319,82 Kb. #676886
Bog'liq
ural xujaqulov dasturlash 2
O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
TELEKOMMUNIKATSIYA TEXNOLOGIYALARI FAKULTETI
DASTURLASH 2 FANI BO’YICHA BAJARGAN
2-Laboratoriya ishi
BAJARDI: XUJAQULOV URAL
TEKSHIRDI:FAYZULLAEVA ZARNIGOR
GURUH:SWD007-L1
TOSHKENT-2022
33-variant
1-topshiriq
Berilgan to’plam juft o’rindagi elementlaridan kalit maydon va qiymatlari 2- to’plam hosil qilinsin. Hamda ikki to’plam elementlari tartiblanmagan va dublikatlarini ham qabo’l qilgan holda ekranga chop etilsin.
#include
#include
#include
using namespace std;
int main()
{
map gquiz1;
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 gquiz2;
map::iterator itr;
cout << "\ngquiz1 map : \n";
cout << "\tKEY\tELEMENT\n";
for (itr = gquiz1.begin(); itr != gquiz1.end(); ++itr)
{
if (itr->first%2==0)
{
gquiz2.insert(*itr) ;
}
cout << '\t' << itr->first << '\t' << itr->second
<< '\n';
}
cout << endl;
cout << "Masala shartlari bajarilgandan so'ng : " << endl ;
cout << "\ngquiz2 map i : \n";
cout << "\tKEY\tELEMENT\n";
for (itr = gquiz2.begin(); itr != gquiz2.end(); ++itr) {
cout << '\t' << itr->first << '\t' << itr->second
<< '\n';
}
cout << endl;
cout << endl;
return 0 ;
}
2-topshiriq
[Переслано от akam]
#include
using namespace std;
int main()
{
unordered_set stringSet ;
stringSet.insert("code") ;
stringSet.insert("in") ;
stringSet.insert("c++") ;
stringSet.insert("is") ;
stringSet.insert("fast") ;
stringSet.insert("c++") ;
string key = "c++" ;
int k = 0 ;
if (stringSet.find(key) == stringSet.end())
cout << key << " Topilmadi" << endl << endl ;
else
{
cout << "Topildi " << key << endl << endl ;
;
}
cout << "\nBarca elementlar : ";
unordered_set :: iterator itr;
for (itr = stringSet.begin(); itr != stringSet.end(); itr++)
cout << (*itr) << endl;
}
Do'stlaringiz bilan baham: