升序: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; }
原文:http://www.cnblogs.com/xlqtlhx/p/6082628.html