#include <stdio.h>
#include <deque>
#include <algorithm>
#include <vector>
using namespace std;
static bool equal(const int a, const int b)
{
return a == b;
}
static void display(const int a)
{
printf("%d ", a);
}
int main()
{
deque<int> a;
a.push_back(1);
a.push_back(1);
a.push_back(2);
a.push_back(2);
a.push_back(4);
std::for_each(a.begin(), a.end(), display);
puts("");
deque<int>::iterator iter = std::unique(a.begin(), a.end());
std::for_each(a.begin(), a.end(), display);
puts("");
a.erase(iter, a.end());
std::for_each(a.begin(), a.end(), display);
puts("");
return 0;
}
stl的unique简单demo
最新推荐文章于 2024-06-24 20:29:51 发布