升序降序 sort 排序
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
#include<vector> //vector
#include<iostream> //sout sin
#include<algorithm> //sort排序算法
bool cmp_down(int a ,int b)//降序函数
{
return a>b;
}
bool cmp_up(int a ,int b)//升序函数
{
return a<b;
}
void main()
{
int nums[]={6,7,8,9,5,4,3,2,1,0};
sort(nums,nums+10,cmp_down); //起始位置,终止位置的后一个,升降序方法
for(int i=0; i<10;i++)
printf("%d ",nums[i]);
}