কম্পিউটার

STL-এ পেয়ার বাস্তবায়নের জন্য C++ প্রোগ্রাম


পেয়ার হল একটি সাধারণ ধারক যা দুটি ডেটা অবজেক্ট নিয়ে গঠিত:

‘first’ = The first element is referenced as ‘first’
‘second’ = the second element and the order is fixed (first, second).

পেয়ার বরাদ্দ, তুলনা এবং অনুলিপি করা যেতে পারে. এটি দুটি মানকে একত্রিত করতে ব্যবহৃত হয় যা প্রকারভেদে ভিন্ন হতে পারে।

সিনট্যাক্স হল :pairvariable name(datavalue1, datavalue2)।

অ্যালগরিদম

Begin
   Write pair<data type1,data type 2>variable name(datavalue1,datavalue2)
   Print the pairs
End

উদাহরণ কোড

#include<iostream>
using namespace std;
int main() {
   pair <char,int> value('a',7);
   pair <string,double> fruit ("grapes",2.30);
   pair <string,double> food ("pulao",200);
   cout<<"The value of "<<value.first<<" is "<<value.second <<endl;
   cout<<"The price of "<<fruit.first<<" is Rs. "<<fruit.second <<endl;
   cout<<"The price of "<<food.first<<" is Rs. "<<food.second <<endl;
   return 0;
}

আউটপুট

The value of a is 7
The price of grapes is Rs. 2.3
The price of pulao is Rs. 200

  1. STL-এ সেট_ইউনিয়ন বাস্তবায়নের জন্য C++ প্রোগ্রাম

  2. STL-এ সেট_সিমেট্রিক_ডিফারেন্স বাস্তবায়নের জন্য C++ প্রোগ্রাম

  3. STL-এ Set_Intersection বাস্তবায়নের জন্য C++ প্রোগ্রাম

  4. STL-এ সেট_ডিফারেন্স বাস্তবায়নের জন্য C++ প্রোগ্রাম