Set1 = { "apple", "banana", "orange", "grape" }
Download 13.9 Kb.
|
Документ 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 set set cout << "Set 1: "; copy(set1.begin(), set1.end(), ostream_iterator cout << endl; cout << "Set 2: "; copy(set2.begin(), set2.end(), ostream_iterator cout << endl; cout << "Set 3: "; copy(set3.begin(), set3.end(), ostream_iterator 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.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 << endl; return 0; } 2.
#include #include #include using namespace std; int main() { srand(time(NULL)); set cout << "elementlar soni: "; cin >> n; multiset 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(); set 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
ma'muriyatiga murojaat qiling