Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

C++: Enregistrer les données transformées dans un ‘deque’

 deque
{filelink=15007}

#include <algorithm>
#include <string>
#include <vector>
#include <deque>
#include <iostream>
#include <functional>
 
using namespace std;
 
int main ()
{
    vector <int> v1, v2;
    for (int num = 0; num < 10; ++ num){
        v1.push_back (num);
        v2.push_back (10 - num);
    }
 
    deque <int> deq (v1.size ());
 
    transform ( v1.begin (), v1.end (), v2.begin (), deq.begin (), plus <int> () );
 
    for (size_t index = 0; index < v1.size (); ++ index)
	{
        cout << index << "    	 " << v1 [index];
        cout << v2 [index]  << " 	  =    ";
        cout << deq [index] << endl;
    }
 
    return 0;
}

No comments yet.

Leave a Comment