how to get last element of set in c++
set<int> s = {1,2,3}
auto it = s.end();
it--;
cout<<*it<<"\n"; // This refers to last element of a set
how to get last element of set in c++
set<int> s = {1,2,3}
auto it = s.end();
it--;
cout<<*it<<"\n"; // This refers to last element of a set
how to get last element of set
// Example program
#include <iostream>
#include <string>
#include <set>
#include <iterator>
using namespace std;
int main()
{
set<int>a = {5,9,100,25,4,6};
auto it = a.end();
it--;
cout << *it;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us