Set1 = { "apple", "banana", "orange", "grape" }


Download 13.9 Kb.
Sana17.06.2023
Hajmi13.9 Kb.
#1539752
Bog'liq
Документ 3 (2)


O’zbekiston Respublikasi Axborot Texnologiyalari va Kommunikatsiyalarini rivojlantirish vazirligi
Muhammad al-Xorazmiy nomidagi Toshkent Axborot Texnologiyalari Universiteti
Mustaqil ish

Guruh: SWD002-5


Bajardi: Alisherov I.B.
Tekshirdi: Babajanov.M.

Toshkent 2023


#include
#include
#include
#include
using namespace std;
int main()
{
set set1 = { "apple", "banana", "orange", "grape" };
set set2 = { "banana", "pear", "pineapple", "grapefruit" };
set set3 = { "orange", "kiwi", "watermelon", "strawberry" };
cout << "Set 1: ";
copy(set1.begin(), set1.end(), ostream_iterator(cout, " "));
cout << endl;
cout << "Set 2: ";
copy(set2.begin(), set2.end(), ostream_iterator(cout, " "));
cout << endl;
cout << "Set 3: ";
copy(set3.begin(), set3.end(), ostream_iterator(cout, " "));
cout << endl;
set1.erase(set2.begin(), set2.end());
set1.erase(set3.begin(), set3.end());
set2.erase(set1.begin(), set1.end());
set2.erase(set3.begin(), set3.end());
set3.erase(set1.begin(), set1.end());
set3.erase(set2.begin(), set2.end());
set collection;
collection.insert(set1.begin(), set1.end());
collection.insert(set2.begin(), set2.end());
collection.insert(set3.begin(), set3.end());
cout << "Collection: ";
copy(collection.begin(), collection.end(), ostream_iterator(cout, " "));
cout << endl;
return 0;
}

2.
#include


#include
#include
#include
using namespace std;
int main()
{
srand(time(NULL));
sets; int n;
cout << "elementlar soni: "; cin >> n;
multisetM, M2;
for (int i = 0; i < n; i++)
{
int j = rand() % n + n; M.insert(j);
j = rand() % n + n; M2.insert(j);
}
auto k2 = M.begin();
sets2;
for (int i = 0; i < n; i++)
{
s2.insert(*k2); k2++;
cout << endl << "M to'plam elementlari: " << endl;
for (auto i = M.begin(); i!=M.end(); i++)
{
cout << *i << " ";
}
cout << endl;
cout << endl << "M2 toplam elementlari:" << endl;
for (auto i = M2.begin(); i != M2.end(); i++)
{
cout << *i << " ";
}
cout << endl << endl << endl << "M1 ning elementlari M2 toplamda qatnashgnlari soni: " << endl;
int soni = 0;
for (auto i = s2.begin(); i != s2.end(); i++)
{
for (auto j = M2.begin(); j != M2.end(); j++)
{
if (M2.count(*i))
{
if(*i == *j);
{
soni++;
}
}
}
if(soni > 0)cout << *i << " - " << soni << " marta " << endl;
else{ cout << *i << " -qatnashmagan " << endl;}
soni = 0;
}
auto k = M.begin(); auto l = M2.begin();
for (int i = 0; i < n; i++)
{
s.insert(*k); k++; s.insert(*l); l++;
}
cout << endl;
cout << endl << "Saralangan toplam elementlari:" << endl;
for (auto i = s.begin(); i != s.end(); i++)
{
cout<< *i<< " ";
}
getchar();
}
}
3,

Download 13.9 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling