Use max_element to get the maximum value : max_element « STL Algorithms Min Max « C++ Tutorial

Home
C++ Tutorial
1.Language Basics
2.Data Types
3.Operators statements
4.Array
5.Development
6.Exceptions
7.Function
8.Structure
9.Class
10.Operator Overloading
11.Pointer
12.File Stream
13.template
14.STL Introduction
15.string
16.vector
17.list
18.bitset
19.set multiset
20.valarray
21.queue stack
22.deque
23.map multimap
24.STL Algorithms Modifying sequence operations
25.STL Algorithms Non modifying sequence operations
26.STL Algorithms Binary search
27.STL Algorithms Sorting
28.STL Algorithms Merge
29.STL Algorithms Min Max
30.STL Algorithms Iterator
31.STL Algorithms Heap
32.STL Algorithms Helper
C / ANSI-C
C Tutorial
C++
Visual C++ .NET
C++ Tutorial » STL Algorithms Min Max » max_element 
29.2.3.Use max_element to get the maximum value
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int main(){
   const float a[] 13.427.615.544.351.230.218.0 };
   vector<float> dataa,a + sizeof/ sizeofa[0] ) );

   float data_min = *min_elementdata.begin(), data.end() );
   float data_max = *max_elementdata.begin(), data.end() );

   cout << data_max;
}
29.2.max_element
29.2.1.Find and print maximum elements in a vector
29.2.2.Use max_element to get the maximum element in a container
29.2.3.Use max_element to get the maximum value
29.2.4.Use max_element with criteria function
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.