cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Outputting end element of a vector
Outputting end element of a vector
Dec 28, 2010 at 1:56pm UTC
assemblyman
(5)
Hi everyone
I have used the stable_sort algorithm to place a vector into ascending order. However I need to out put the largest value ( which will be the end value).
Would someone be able to tell me how to do this?
Thank you!
Dec 28, 2010 at 2:14pm UTC
filipe
(1165)
The last element of a vector v is
*(v.end() - 1)
or
*(v.rbegin())
or
v[v.size() - 1]
.
Last edited on
Dec 28, 2010 at 2:14pm UTC
Dec 28, 2010 at 2:20pm UTC
assemblyman
(5)
Thank you so much! :-)
Topic archived. No new replies allowed.