JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat (newest first)  | Threaded  | Tree Previous Thread  |  Next Thread Forums Tutorial Discussions Binary Search tutorial Question about max_element and accumulate fuction
 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)