এই টিউটোরিয়ালে আমরা C++ STL-এ ভেক্টারের ম্যাক্সিমাম এলিমেন্ট কীভাবে বের করতে হয় সেটা নিয়ে আলোচনা করব।
একটি দেওয়া ভেক্টার থেকে ম্যাক্সিমাম এলিমেন্ট বের করতে আমরা STL লাইব্রেরির *max_element() মেথড ব্যবহার করব।
উদাহরণ
#include <bits/stdc++.h> using namespace std; int main(){ //defining the vector vector<int> a = { 1, 45, 54, 71, 76, 12 }; cout << "Vector: "; for (int i = 0; i < a.size(); i++) cout << a[i] << " "; cout << endl; //finding the maximum element cout << "Max Element = " << *max_element(a.begin(), a.end()); return 0; }আউটপুট
Vector: 1 45 54 71 76 12 Max Element = 76