c++中sort()函数的用法简介

代码:

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
    int a[] = {1,4,3,3,2,2,5,7,5,6};
    sort(a, a + sizeof(a) / sizeof(int));
    for (auto it = a; it != a + sizeof(a) / sizeof(int); it++)
    {
        cout << *it << " ";
    }
    cout << endl;
    system("pause");
    return 0;
    return 0;
}

运行结果:

猜你喜欢

转载自blog.csdn.net/qq_33221533/article/details/82729388