This should help you find the second largest if you sort in descending order, meaning you do this sort(v.rbegin(), v.rend());
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
int second; // Holds the second largest number
int index = 1; // Used to iterate through the vector
// If the second element is the same as the first
// it isn't the second largest number so we go to the
// next element, and so on untill it is not egual to the element
// before it.
if (v[index] == v[index-1])
second = v[index];
cout << "Second Largest: " << second << endl;
We do this because we could have something likes this for our numbers
10 - First Element
10 - Second Element
10 - Third Element
9 - Fourth Element - This one will be the second largest
So if we just told the program to print the second element in the vector it would print '10' which as we can see is not the second highest number.
Nope check out our posts before to see why. You were almost there with the code you had before except for one thing which is what happens if the highest number gets repeated twice, or more? Basically delete everything after line 23 and then post the code I pasted in there where you just deleted everything. Except change everything with v to numbers  obviously
Make sure you just don't copy and paste and call it good though. Make sure you study it and see what it is doing and understand why you need to do it. Catfish explains why you need to do it well in his recent post.
P.S Like your formatting a lot better now great improvement on that.