Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Trouver le plus pétit élément dans le vecteur

 list, list, vecteur, iterator
{filelink=15169}

#include <iostream>
#include <vector>
#include
<list>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <numeric>
 
using namespace std;
 
int main()
{
    vector<int> coll;
    ostream_iterator<int> output(cout, " ");
 
    for(int x=-3; x<=5; x++)
		coll.push_back(x);
 
	cout<<"Le contenu de la collection: ";
	copy(coll.begin(), coll.end(), output);
	cout<<endl;
 
    //Trouver la plus pétite valeur
    cout << "min: "
         << *min_element(coll.begin(),coll.end())
         << endl;
	return 0;
 
}

No comments yet.

Leave a Comment