C++中有一个sort函数,能够快速排序,
这个函数需要用到
#include<algorithm> using namespace std; sort(num, num + n, cmp);
如果cmp返回结果为假, 那么函数就会将他们互换位置;
如果cmp返回结果为真,就会保持原来位置不变。