#include <iostream>
#include <algorithm>
#include <vector>
int main()
{
std::vector<int> v{1, 2, 2, 2, 3, 3, 2, 2, 1};
std::vector<int>::iterator last;
last = std::unique(v.begin(), v.end());
for (std::vector<int>::iterator it = v.begin(); it != last; ++it) {
std::cout << *it << " ";
}
std::cout << "\n";
return 0;
}
Si fuera C++, unique quita los elementos consecutivos repetidos dentro de un rango (first, last).
Jorge Fortes
- 41
- 8