常用排序算法sort
发布日期:2022-03-04 12:48:36 浏览次数:24 分类:技术文章

本文共 517 字,大约阅读时间需要 1 分钟。

黑马251

#include
#include
#include
#include
#include
using namespace std;

void test01()

{
vectorv;
v.push_back(2);
v.push_back(1);
v.push_back(5);
v.push_back(3);
v.push_back(4);
sort(v.begin(), v.end());
for (vector::iterator it = v.begin(); it != v.end(); it++)
{
cout << *it << " ";
}
cout << endl;

//改变为降序sort(v.begin(), v.end(), greater
());for (vector
::iterator it = v.begin(); it != v.end(); it++){ cout << *it << " ";}cout << endl;

}

//自定义数据类型

void test02()
{

}

int main()
{
test01();
}

转载地址:https://blog.csdn.net/qq_43752920/article/details/120551863 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:查找算法count_if
下一篇:排序算法-洗牌算法

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年03月22日 02时44分38秒