vector 排序 去重 反向输出

#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
vector<int> Vector;
Vector.push_back(100);
Vector.push_back(100);
Vector.push_back(400);
Vector.push_back(300);
Vector.push_back(200);
sort(Vector.begin(),Vector.end());  //排序
Vector.erase(unique(Vector.begin(), Vector.end()),Vector.end()); //去重
cout << Vector.size() << endl;
for (vector<int>::reverse_iterator it = Vector.rbegin(); it != Vector.rend(); ++it)  //反向访问
{
cout << *it << endl;
}


return 0;
}

阅读更多
文章标签: vector iterator include
个人分类: C/C++
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭