#include <vector>
#include <algorithm>
#include <iostream>
int main()
{
std::vector<int> v1(10);
std::vector<int> v2(18);
std::vector<int> v3(5);
std::vector<int> v4(8);
std::vector<int> v5(16);
std::vector<int> v6(20);
std::vector<int> v7(7);
std::vector < std::pair<int, int>> VIndex;
VIndex.push_back(std::make_pair((int)v1.size(), 1));
VIndex.push_back(std::make_pair((int)v2.size(), 2));
VIndex.push_back(std::make_pair((int)v3.size(), 3));
VIndex.push_back(std::make_pair((int)v4.size(), 4));
VIndex.push_back(std::make_pair((int)v5.size(), 5));
VIndex.push_back(std::make_pair((int)v6.size(), 6));
VIndex.push_back(std::make_pair((int)v7.size(), 7));
std::sort(begin(VIndex), end(VIndex), [](const std::pair<int, int>& LeftItem, const std::pair<int, int>& RightItem)
{
return LeftItem.first > RightItem.first;
});
for (auto item : VIndex)
{
std::cout << item.second << std::endl;
}
getchar();
return 0;
}
对容器数组内的容器按照大小进行编号排序demo02
最新推荐文章于 2021-10-10 13:14:56 发布