কম্পিউটার টিউটোরিয়াল

সি++ STL-এ মাল্টিসেট upper_bound() উদাহরণসহ (multiset upper_bound() in C++ STL with Examples)


এই টিউটোরিয়ালে, আমরা সি++ STL-এ মাল্টিসেট upper_bound() ফাংশন সম্পর্কে আলোচনা করব।

upper_bound() ফাংশনটি প্যারামিটারের চেয়ে বড় এলিমেন্টের পয়েন্টার রিটার্ন করে, না থাকলে কন্টেইনারের শেষ এলিমেন্টের পয়েন্টার রিটার্ন করে।

উদাহরণ

#include <bits/stdc++.h> using namespace std; int main(){    multiset<int> s;    s.insert(1);    s.insert(3);    s.insert(3);    s.insert(5);    s.insert(4);    cout << "The multiset elements are: ";    for (auto it = s.begin(); it != s.end(); it++)       cout << *it << " ";    auto it = s.upper_bound(3);    cout << "\nThe upper bound of key 3 is ";    cout << (*it) << endl;    it = s.upper_bound(2);    cout << "The upper bound of key 2 is ";    cout << (*it) << endl;    it = s.upper_bound(10);    cout << "The upper bound of key 10 is ";    cout << (*it) << endl;    return 0; }

আউটপুট

The multiset elements are: 1 3 3 4 5 The upper bound of key 3 is 4 The upper bound of key 2 is 3 The upper bound of key 10 is 5

  1. C++ STL-এ Vector বাস্তবায়ন: ডাইনামিক অ্যারে ব্যবহার

  2. C++ STL-এ Multiset বাস্তবায়ন: ডুপ্লিকেট অনুমোদিত সেট

  3. C++ STL-এ List বাস্তবায়ন: ডাবলি লিংকড লিস্ট

  4. C++ STL-এ Forward List বাস্তবায়ন: সিঙ্গলি লিংকড লিস্ট