О‘ZBEKISTON RESPUBLIKACI OLIY VA О‘RTA MAXSUS TA’LIM VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI NURAFSHON FILIALI
“Kompyuter injiniringi” fakulteti
Guruh nomi: 410-21
F.I.SH: Muxammadov Jayxunbek ning
bajargan
№ 2 - Laboratoriya ishi
1-Vazifa:
a) Berilgan char turidagi to‘plamning 2 ta elementidan 2- to‘plamni, 3 ta elementidan 3- to‘plamni hosil qiluvchi va ularni ekranga chiqaruvchi dastur tuzing.
Bajarilishi:
#include
#include
using namespace std;
int main ()
{
char meningcharim[] = {'d','t','h','w','n','c','z'};
multiset toplam (meningcharim,meningcharim+7);
multiset toplam2;
multiset toplam3;
multiset::iterator it;
multiset::iterator it2;
multiset::iterator it3;
int k=0;
cout << "Berilgan toplam:";
for ( it=toplam.begin(); it!=toplam.end(); ++it)
cout<<" "<<*it;
for ( it=toplam.begin(); it!=toplam.end(); ++it)
{++k;
if (k<6)
if (k<3)
toplam2.emplace(*it);
else
toplam3.emplace(*it);
else
break;
}
cout<<"\n 2-toplamdagi ellementlar: ";
for(it2=toplam2.begin(); it2!=toplam2.end(); ++it2)
cout<<" "<<*it2;
cout<<"\n 3-toplamdagi ellementlar: ";
for(it3=toplam3.begin(); it3!=toplam3.end(); ++it3)
cout<<" "<<*it3;
cout << '\n';
return 0;
}
b) Ho‘l mevalar haqida (nomi, mazasi, rangi, turi va narxi) to‘plam berilgan. Ho‘l mevalarning nomi, mazasi, rangi, turi va narxi bo‘yicha qidiruvchi hamda topilgan natijani faylga saqlashni taklif qiladigan dastur tuzing.
Bajarilishi:
#include
#include
#include
#include
using namespace std;
int main () {
map < string , string> nomi;
map < string , string> mazasi;
map < string , string> rangi;
map < string , float> narxi;
nomi.emplace("Olma","Olma");
mazasi.emplace("Olma","Shirali");
rangi.emplace("Olma","Kok");
narxi.emplace("Olma",1.5);
nomi.emplace("Behi","Behi");
mazasi.emplace("Behi","Nordon");
rangi.emplace("Behi","Sariq");
narxi.emplace("Behi",2.1);
nomi.emplace("Olcha","Olcha");
mazasi.emplace("Olcha","Sho'rroq");
rangi.emplace("Olcha","Qizil");
narxi.emplace("Olcha",0.8);
cout<<"Bizda 3 ta meva bor: Olma, Behi, Olcha.\n";
cout<<"qidirmoqchi bolgan mevani nomini kiriting:\n";
char s[10];
cin>>s;
cout<<"\n\nMeva Nomi: "<second;
cout<<"\nMeva mazasi: "<second;
cout<<"\nMeva rangi: "<second<<" rangli;";
cout<<"\nMeva narxi: "<second<<"$";
ofstream fayl;
fayl.open("Yozish.txt");
cout<<"\n\n Shu natijalar faylga saqlansinmi: 1 yoki 0 ni kiriting: ";
int q;
cin>>q;
if (q)
{
fayl<second<second;
fayl<second<second;
cout<<"\nMuvaffaqqiyatli Yozildi!.";
}
else
{
cout<<"Faylga yozilmadi. Rahmat";
}
}
2-Vazifa:
Navbat berilgan ekrandan kiritilgan sondan qiymati katta elementlarni toping.
Bajarilishi:
#include
#include
#include
using namespace std;
int main () {
int n,x;
cout<<"Navbatga Nechta son kiritmoqchisiz: ";
cin>>n;
queue jay;
for (int i=0; i{
cin>>x;
jay.push(x);
}
cout<<"\n Endi sondan katta sonlarni chiqarish uchun son kiriting: ";
cin>>x;
while(!jay.empty())
{
if (jay.front()>x) cout<jay.pop();
}
}
Asosiy adabiyotlar:
Moʻminov B.B., Dasturlash I. Oʻzbekiston Respublikasi Oliy va oʻrta maxsustaʻlim vazirligi. – T.: «NAMUNA», 2020. –311 b.
Nazirov SH.A., Qobulov R.V., Bobojanov M.R., Raxmanov Q.S. S va C++ tili. “Voris- nashriyot” MCHJ, Toshkent 2013, 488 b.
Horstmann, Cay S. C++ for everyone/Cay S. Horstmann. Printed in the United States of America - 2nd ed. 2010. – P. 562.
Horton I.-Beginning Visual C++ 2012/ I.Horton. Published simultaneously in Canada.–2012. –P. 988.
https://drive.google.com/file/d/1Ans7TBsQBsX_tMIYxURZcLkc_Kp7sAiX/view?usp=sharing
https://drive.google.com/file/d/1HYvMsbIsgUYGfWJj_uxxiR_S9G6G2Q-O/view?usp=sharing
Do'stlaringiz bilan baham: |