Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Supprimer les répétitions consécutives avec l’algorithme ‘unique_copy()’

 list, list, iterator
{filelink=15126}

 
#include <iostream>
#include
<list>
#include <algorithm>
#include <string>
 
using namespace std;
 
int main( ) {
   string tabStr[6] = {"A", "A" , "B", "A", "D", "E"};
 
   list<string> coll;
   copy(tabStr, tabStr+6,  back_inserter(coll)); 
 
   unique_copy(coll.begin(), coll.end(),
	    ostream_iterator<string>(cout," "));
		return 0;
}

No comments yet.

Leave a Comment