#include <bits/stdc++.h> using namespace std; int main() { vector<int> v = {1, 1, 2, 4, 5, 5, 6, 7, 8, 8}; sort(v.begin(), v.end()); // 把v中重复的元素放到p迭代器的后边 auto p = unique(v.begin(), v.end()); v.erase(p, v.end()); return 0; }