- #include <vector>
- #include <functional>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- using std::vector;
- vector<int> vInts;
- vInts.push_back(4);
- vInts.push_back(2);
- vInts.push_back(3);
- vInts.push_back(1);
- //降序排序
- //sort(vInts.begin(), vInts.end(),greater<int>());
- //升序排序
- sort(vInts.begin(), vInts.end(),less<int>());
- for ( int i=0; i<4; i++ )
- printf("%d\n",vInts[i]);
- return 0;
- }
C++ vector容器使用 排序
最新推荐文章于 2025-02-27 14:48:10 发布
742

被折叠的 条评论
为什么被折叠?



