STL : max_element () + min_element ()


#include
#include
#include
using namespace std;

int main ()
{
int x [] = {2, 7, 92, 81, 19, 72, 23};

unsigned int array_length = sizeof (x) / sizeof (int);

cout << "Maximum : " << *max_element (x, x + array_length) << endl; vector v;

v.push_back (‘k’);
v.push_back (‘f’);
v.push_back (‘g’);
v.push_back (‘b’);

cout << "Minimum : " << *min_element ( v.begin (), v.end () ) << endl; return 0; } /* output Maximum : 92 Minimum : b Process returned 0 (0x0) execution time : 0.078 s Press any key to continue. */ [/sourcecode]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s