topshiriq quyidagi metodlarni izohlang begin
Download 171.2 Kb.
|
2-topshiriq. MAP (2) (2)
#include #include using namespace std; int main(){ map {{'#',35}, {'+', 43}, {'0', 48}, {'1', 49}, {'2', 50}, {'3', 51}, {'4', 52}, {'5', 53}, {'6', 54}, {'7', 55}, {'8', 56}, {'9', 57}, {'A', 65}, {'B', 66}, {'C', 67}, {'D', 68}, {'E', 69}, {'F', 70}, {'G', 71}, {'H', 72}, {'I', 73}, {'J', 74}, {'K', 75}, {'L', 76}, {'M', 77}, {'N', 78}, {'O', 79}, {'P', 80}, {'Q', 81}, {'R', 82}, {'S', 83}, {'T', 84}, {'U', 85}, {'V', 86}, {'W', 87}, {'X', 88}, {'Y', 89}, {'Z', 90}, {'a', 97}, {'b', 98}, {'c', 99}, {'d', 100}, {'e', 101}, {'f', 102}, {'g', 103}, {'h', 104}, {'i', 105}, {'j', 106}, {'k', 107}, {'l', 108}, {'m', 109}, {'n', 110}, {'o', 111}, {'p', 112}, {'q', 113}, {'r', 114}, {'s', 115}, {'t', 116}, {'u', 117}, {'v', 118}, {'w', 119}, {'x', 120}, {'y', 121}, {'z', 122} }; int i,m; char a,b; cout<<"nechta juftlik qo'shmoqchisiz ? "; cin>>m; for(i=1; i<=m; i++){ cout<<"kalitni kiriting "; cin>>a; cout<<"qiymatni kiriting "; cin>>b; semvol.insert(pair } for(auto it=semvol.begin(); it!=semvol.end(); it++) if('A'==it->first or 'E'==it->first or 'I'==it->first or 'O'==it->first or 'U'==it->first or 'Y'==it->first or 'a'==it->first or 'e'==it->first or 'i'==it->first or 'o'==it->first or 'u'==it->first or 'y'==it->first) cout< } 14) Map hosil qiling. Uni elementlar bilan to’ldiring. M kalitni kiriting agar kalit mavjud, bo’lsa o’chirsin aks holda mapda bunday kalit yo’qligi haqida xabar bersin. #include #include using namespace std; int main(){ map int i,n,k,s=0; string a,b,m; cout<<" nechta elementlar juftligini qo'shmoqchisiz ? "; cin>>n; for(i=1; i<=n; i++){ cout<<"kalitni kiriting "; cin>>a; cout<<"qiymatni kiriting "; cin>>b; tekshiruv.insert(pair } l: cout<<" map da m kalit va qiymatini o'chiring m="; cin>>m; for( auto it=tekshiruv.begin(); it!=tekshiruv.end(); it++){ s++; if(m==it->second or m==it->first) tekshiruv.erase(it->first);} k=tekshiruv.size(); if(s==k) cout<<"o'chirish uchun element topilmadi "< for(auto it=tekshiruv.begin(); it!=tekshiruv.end(); it++) cout< goto l; } 15) Lugat dan iborat map hosil qiling. Kalitga mos qiymatlarni kiriting. Agar tarjima to’g’ri bo’lsa, yakunida jammi ball hisoblansin. Har bir to’g’ri so’z 1 balldan baholang. #include #include using namespace std; int main(){ map {{"apple" , "olma"}, {"book","kitob"}, {"pen", "ruchka"}, {"teacher", "o'qituvchi"}, {"lemon","limon"}, {"horse","ot"}, {"peach", "shaftoli"}, {"home","uy"}, {"work","ish"}, {"water","suv"}, {"hello","salom"}, {"umbrella","soyabon"}, {"car","avtomabel"}, {"box", "quti"}, {"word","so'z"}, {"phone","telefon"}, {"end","tamom"}, {"fox","tulki"}, {"zebra","zebra"}, {"crocodel","timsoh"} }; int s=0,k; string a; k=tarjima.size(); cout<<"tarjima qiling "< for(auto it=tarjima.begin(); it!=tarjima.end(); it++){ cout< if(a==it->second) s++;} cout< if(s>16) cout<<" A'LO "; else if(s>12 and s<=16) cout<<" YAXSHI "; else if(s>8 and s<=12) cout<<" QONIQARLI "; else if(s>4 and s<=8) cout<<" QONIQARSIZ "; else cout<<" QAYTA URINIB KO'RING "; cout<<" siz "< } 16) Matematik misollar va ularning natijasi berilgan. Agar o’quvchi masalalarni to’g’ri yechsa, 2 balldan xató yechsa 1 balldan kamaytirib umumiy ballni hisoblovchi dastur tuzing. #include #include using namespace std; int main(){ map {{"2+3/2=", 3.5}, {"18*13-17*14=",-4}, {"Teng tomonli uchburchakning tomoni 6 ga teng.Uning peremetrini toping.", 18}, {"Ali va Valida bir necha sumdan pul bor. Agar Vali Aliga 2 sum pul bersa," "ularning pullari terng bo'ladi. Agar Ali Valiga 2 sum pul bersa Valining puli Alining pulidan " " 2 marta ko'p bo'ladi. Valida qancha pul bor ? ", 14}, {"mm da ifodalang. 2dm 23sm 11mm=",441}, {"3 gektar necha sotix ? ", 300}, {"Arifmetik progressiyaning birinchi hadi 3 ga yettinchi hadi esa 15 ga teng" " shu arifmetik progrissiyaning dastlabgi 10 ta hadi yig'indisini toping. ",120}, {"Bir quvur bo'sh hovuzni 4 soatda toldiradi. Ikkinchi quvur esa xuudi shu hovuzni 6 soatda to'ldiradi. " " Ikkala quvur birgalikda shu hovuzni necha soatdda to'ldiradi ? ",2.4}, {"2+2=",4}, {"Raqamlari yig'indisidan 2 marta katta bo'lgan sonni toping. ",18} }; int s=0,k; float a; k=matematika.size(); cout<<"masalalarni javobini toping "< for(auto it=matematika.begin(); it!=matematika.end(); it++){ cout< if(a==it->second) {s+=2; cout<<"T"< cout< if(s>8) cout<<" A'LO "; else if(s>6 and s<=8) cout<<" YAXSHI "; else if(s>4 and s<=6) cout<<" QONIQARLI "; else if(s>2 and s<=4) cout<<" QONIQARSIZ "; else cout<<" QAYTA URINIB KO'RING "; cout<<" siz "<<2*k<<" balldan "< } 17) Shunday dastur tuzing, kiritilgan o’nlik sonni ikkilik sanoq sistemasiga aylanitirib bersin. (Mapni o’nlik va ikkilikdagi qiymati bilan to’ldiring) 1) #include #include using namespace std; int ikkilik_sanoq(int a) { long long int b,s=0,k=0; for(;;){ s=s+a%2*pow(10,k); k++; a=a/2; if(a<2) {s=s+a*pow(10,k); break;} } return s; } int main() { long long int k,a; cout<<"o'nlikda a="; cin>>a; k=ikkilik_sanoq(a); cout<<"k="< } 2) #include #include using namespace std; int main() { map {{0,0}, {1,1}, {2,10}, {3,11}, {4,100}, {5,101}, {6,110}, {7,111}, {8,1000}, {9,1001}, {10,1010}, {11,1011}, {12,1100}, {13,1101}, {14,1110}, {15,1111} }; int a; cout<<"ikkilik sanoq sistemsiga o'tkazing "; cin>>a; for(auto it=ikkilik.begin(); it!=ikkilik.end(); it++) if(a==it->first) cout< } 18) Map hosil qiling va pifogor jadvali bilan to’ldiring. Ixtiyoriy kiritilgan n karaning jadvalini chop eting. #include #include using namespace std; int main() { multimap int a,i,j; for(i=1; i<=10; i++) for(j=1; j<=10; j++) pifagor.insert(pair cout<<"Necha karra jadvali kerak ? "; cin>>a; for(auto it=pifagor.begin(); it!=pifagor.end(); it++) if(a==it->second) cout< } 19) Map hosil qiling va uni n ta juftlik bilan to’ldiring. Kalit va qiymatni almashtirib, chop eting. #include #include using namespace std; int main() { map int i,n,b; string a; cout<<" nechta juftlikdan iborat map yaratmoqchisiz ? "; cin>>n; for(i=1; i<=n; i++){ cout<<"kalitni kiriting "; cin>>a; cout<<"qiymatni kiriting "; cin>>b; xesh.insert(pair } for(auto it=xesh.begin(); it!=xesh.end(); it++) cout< } 20) O’quvchi mapda mavjud bo’lgan inglizcha so’zni kiritsa, o’zbekcha tarjimasini, o’zbekcha kiritsa esa inglizchasini chiqaruvchi dastur tuzing. #include #include Download 171.2 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling