O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
Muhammad Al-Xorazmiy nomidagi Toshkent Axborot Texnologiyalari Universiteti
Dasturlash 2 fanidan
3 - Topshiriq
Topshirdi: Sharipov Temur
Tekshirdi: Cho’liyev Shoxrux
Guruh: SDW005-L2
Variant 25
Topshiriq №1
#include
#include
#include
#include
using namespace std;
int main(){
multiset s1;
multiset s2;
multiset s3;
s1.insert(40.5);
s1.insert(30.2);
s1.insert(60.8);
s1.insert(20.4);
s1.insert(50.1);
s1.insert(50.6);
s1.insert(10.9);
s1.insert(11.7);
multiset::iterator itr;
multiset::iterator itrr;
int k = 1, x = 0;
int a = 0, b = 0;
cout << "Dastlabki holat : ";
for (itr = s1.begin(); itr != s1.end(); itr++) {
cout << *itr << " ";
if(k!=2) {
a = *itr;
k+=1;
} else {
b = *itr;
k = 1;
s2.insert(a+b);
s3.insert(a-b);
}
x = *itr;
}
cout << endl;
if(s1.size()%2==1) {
s2.insert(x);
s3.insert(x);
}
cout << "Yaxlitlangan har ikkita elementlarning yig'indisi: ";
for (itrr = s2.begin(); itrr != s2.end(); itrr++) {
cout << *itrr << " ";
}
cout << endl;
cout << "Yaxlitlangan har ikkita elementlarning ayirmasi: ";
for (itrr = s3.begin(); itrr != s3.end(); itrr++) {
cout << *itrr << " ";
}
return 0;
}
Topshiriq №2
#include
#include
Do'stlaringiz bilan baham: |