Algorithm头文件中的sort函数使用
来源:互联网 发布:神奇网络热血霸业下载 编辑:程序博客网 时间:2024/05/22 19:29
#include "stdafx.h"#include<iostream>#include<algorithm>#include<string>#if 0int _tmain(int argc, _TCHAR* argv[]){int a[10] = {9,12,17,30,50,20,60,65,4,49};std::sort(a, a + 10);for (int i = 0; i < 10; i++)std::cout << a[i] <<" ";std::cout << std::endl;system("pause");return 0;}#endif#if 1bool compare(int a, int b){return a < b; //默认的升序排序,如果改为return a>b,则为降序}bool compare_decrease(int a, int b){return a > b; //从大到小的排序}int main(){int a[10] = { 9, 12, 17, 30, 50, 20, 60, 65, 4, 49 };std::sort(a, a + 10);for (int i = 0; i < 10; i++)std::cout << a[i] << " ";std::cout << std::endl;std::sort(a, a + 10, compare_decrease);for (int i = 0; i < 10; i++)std::cout << a[i] << " ";std::cout << std::endl;system("pause");return 0;}#endif
阅读全文
0 0
- Algorithm头文件中的sort函数使用
- 用<algorithm>头文件中的sort函数排序
- 头文件 algorithm 中的常用函数
- <algorithm>中的sort()函数
- algorithm头文件里的使用函数
- c++-algorithm 头文件排序sort
- c++-algorithm 头文件排序sort
- Algorithm头文件中的next_permutation全排列函数
- C++中的algorithm头文件
- Algorithm 头文件中的算法
- 关于algorithm头文件的count函数
- algorithm头文件里的函数
- 容器常用函数、algorithm头文件
- algorithm头文件里的函数
- algorithm头文件里的函数
- 头文件<algorithm>中next_permutation函数
- algorithm头文件下的常用函数
- C++中的 头文件”#include<algorithm>“
- 快速排序
- OpenStack Newton版本部署 ---- 镜像服务(glance)
- JS简易日历
- JAVA笔记-14
- OpenStack Newton版本部署----计算服务(nova)
- Algorithm头文件中的sort函数使用
- C++随记(一)---字符串数组的输入问题
- faster rcnn解析之stage1_rpn_solver60k80k.pt
- PHP面试之文件夹下内容重复的文件去重
- IO输出输入流
- NYOJ-353 3D地图搜索
- C++字符串数组
- 360浏览器下自动填写用户名密码惹祸了
- Count of Smaller Numbers After Self