JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (newest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
Question about max_element and accumulate fuction | Reply
Hi, I am newbe in computer science field.
what is the max_element and accumulate function doing for?

why lo and hi equal to them?


int lo = *max_element( folders.begin(), folders.end() );
int hi = accumulate( folders.begin(), folders.end(), 0 );
Re: Question about max_element and accumulate fuction (response to post by ssuchieh) | Reply
max_element() returns an iterator to the max element in the list (vector, set, or whatever).. So, if you want the value (and not the position the element is), you have to dereference using the * operator.

accumulate() returns the sumation of the elements in the list (vector, set, or whatever) plus an additional that you pass as (third) argument (often you use 0)

I think you don't disturb anyone doing these basic questions but you can save your time searching for your answers here: www.google.com
If your questions are about C++, you can look at http://www.cppreference.com and if you are searching specifically for stl functions: http://www.cpprInternal Error

Your request could not be processed. Please inform TopCoder.