首页 > 代码库 > sort

sort

升序:sort(begin,end,less<data-type>());
降序:sort(begin,end,greater<data-type>()).
int _tmain(int argc, _TCHAR* argv[])
{
int a[20]={2,4,1,23,5,76,0,43,24,65},i;
for(i=0;i<20;i++)
cout<<a[i]<<endl;
sort(a,a+20,greater<int>());
for(i=0;i<20;i++)
cout<<a[i]<<endl;
return 0;
}

  

sort