Va kommunikatsiyalarni rivojlantirish vazirligi
Download 149.8 Kb.
|
O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARNI RIVOJLANTIRISH VAZIRLIGI MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI Tizimli va amaliy dasturlashtirish kefedrasi Ma’lumotlar tuzilmasi va algoritmlar fani bo’yicha Amaliy ish Mavzu: Ma’lumotlarning oddiy va sozlangan turlari Bajardi : 513-22 - guruh talabasi Mahmudov Shamsxon Tekshirdi : Bo’riyev Yusuf Toshkent-2023 Masala : #include #include using namespace std; struct MultiKeyElement { int key1; int key2; }; struct CompareElements { bool operator()(const MultiKeyElement& elem1, const MultiKeyElement& elem2) const { if (elem1.key1 == elem2.key1) { return elem1.key2 < elem2.key2; } return elem1.key1 < elem2.key1; } }; int main() { set {10, 15}, {20, 25}, {30, 35}, {40, 45}, {50, 55}, {60, 65}, {70, 75}, {80, 85}, {90, 95}, {100, 195}, }; int targetKey1 = 100; int targetKey2 = 105; int comparisons = 5; MultiKeyElement targetElement{targetKey1, targetKey2}; auto iter = elements.find(targetElement); if (iter != elements.end()) { int index = distance(elements.begin(), iter); cout << "Element " << index << " - indexda joylashgan " << endl; } else { cout << "Element topilmadi" << endl; } cout << "Taqqoslashlar soni : " << comparisons << endl; } Download 149.8 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling