#include#include int main() { std::multiset nums = {5, 2, 8, 5, 1, 9}; // print the greatest element std::cout << *nums.rbegin() << std::endl; return 0; }
#includeThis code creates a multiset called "nums" with six integers and then iterates through it in reverse order using the rbegin and rend functions. Package/Library: C++ Standard Library (STL)#include int main() { std::multiset nums = {5, 2, 8, 5, 1, 9}; // print all elements in reverse order for (auto itr = nums.rbegin(); itr != nums.rend(); ++itr) { std::cout << *itr << " "; } std::cout << std::endl; return 0; }