STL Vectors — Print two highest values in list in descending order

vector<int> numbers = {5, 13, 7, 24};
sort(nums.rbegin(), nums.rend());
sort(nums.begin(), nums.end(), greater<int>());
cout << nums[0] << ", " << nums[1] << endl;

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store