I'm not sure why the following snippet is not working: lower_bound return of call 7 , Which is expected to return std :: max_element between start () and lower_bound () iterator 6, because this key is 4 And should search between key 7 and 6 for maximum value 6. But this is returning the last pair (15, 12) back to some reason I do not understand.
bool CMP (Constant :: :: pair and TT; T, T & G; P1, Const CTD :: Jodi and LT; T, T & G; P2) {Return P 1 Seasoned & lt; P2.second; } Int main () {std :: map & lt; T, T, Stud :: Big & lt; T & gt; & Gt; shop; Std :: map & lt; T, T, Stud :: Big & lt; T & gt; & Gt; :: error found_max, less; Store [4] = 2; Store [7] = 6; Store [10] = 2; Store [15] = 12; Less = store.lower_bound (8); Printf ("% ld% ld \ n", lower-> first, lower-> second;); Found_max = std :: max_element (store.begin (), lower, CMP); Printf ("% ld% ld \ n", found_max-> first, found_max-> second); Return 0; }
std :: map & lt; T, T, Stud :: Big & lt; T & gt; & Gt; shop; store key is sorted into descending order, [store.begin (), less) contains (15, 22) and (10, 2) . The element with the maximum value is (15, 22) .
No comments:
Post a Comment