//
// Created by wuyongyu on 2019-10-10.
//
#include <iostream>
#include <string>
#include <thread>
#include <mutex>
#include <chrono>
#include <vector>
#include <future>
#include <condition_variable>
using namespace std::chrono_literals; // for sleep_for(10s)
using namespace std;
int main() {
std::vector<int> numbers{1,2,2,3,4,4,7,8};
std::vector<int>::iterator a= std::unique(numbers.begin(), numbers.end(), [](const int& a,
const int& b) {
return a ==b;
});
numbers.erase(a, numbers.end());
cout << numbers.size();
return 0;
}
c++ vector删除元素,使用unique ,erase
最新推荐文章于 2024-03-12 22:05:20 发布