C++ vector容器使用 排序

[cpp] view plaincopyprint?
#include

#include
#include
#include


using namespace std;

int main()
{
using std::vector;
vector vInts;

vInts.push_back(4);
vInts.push_back(2);
vInts.push_back(3);
vInts.push_back(1);

//降序排序
//sort(vInts.begin(), vInts.end(),greater());

//升序排序
sort(vInts.begin(), vInts.end(),less());

for ( int i=0; i<4; i++ )
printf("%d\n",vInts[i]);


return 0;
}

你可能感兴趣的:(C++)