Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Calculer les differences successives entres les éléments d’une collection à l’aide de la fonction ‘adjacent_difference’

 calcul, deque, iterator
{filelink=15270}

#include 
#include 
#include 
#include 
#include 
#include 
 
using namespace std;
 
int main()
{
   deque deq;
   ostream_iterator output( cout, " " );
 
    for (int i=1; i<=10; ++i)
	{
        deq.insert(deq.end(),i);
    }
 
   cout << "Contenu du deque: n";
   copy( deq.begin(), deq.end(), output );
 
    cout << endl;
   // Comparer et afficher les résultat
 
   adjacent_difference (deq.begin(), deq.end(),         // source
                        ostream_iterator(cout," ")); // dest.
   cout << endl;
 
return 0;
}
 
/*
Contenu du deque:
1 2 3 4 5 6 7 8 9 10
1 1 1 1 1 1 1 1 1 1
 
 */

No comments yet.

Leave a Comment