数据结构之poj2388
来源:互联网 发布:奇迹暖暖网络连接失败 编辑:程序博客网 时间:2024/04/29 08:27
第一眼看是快排思想,于是复习了快排!
复习了快排代码:
void quicksort(int a[], int low,int high){//low,high分别代表要排序的数组上限和下限if(low>=high)return;int first=low;int last=high;int key=a[first];while(first<last){while(first<last&&a[last]>=key)last--;a[first]=a[last];while(first<last&&a[first]<=key)first++;a[last]=a[first];}a[first]=key;//到此为止,first左边的那些值都比key小,右边的那些值都比key大quicksort(a,low,first-1);quicksort(a,first+1,high);}然后编译错误,我心痛啊!结果是因为最后输出忘加回车!!!一定要记住!!!
然后发现有现成的函数啊!sort函数是<algorithm>里的,但是根本没快排耗时短!
而且可以动态申请数组,int *milk=new int[n];
就酱~
0 0
- 数据结构之poj2388
- poj2388
- POJ2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- POJ2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- poj2388
- 小结SpringMVC(三)
- Android开发:最详细的 Toolbar 开发实践总结
- 分类器组合方法Bootstrap, Boosting, Bagging, 随机森林(一)
- elementFormDefault="qualified"
- mysql数据库相关基本术语和概念
- 数据结构之poj2388
- Win7家庭版开启Administrator管理员帐户的方法
- c++第7次实验——最大公约和和最小公倍数
- IOS开发(转载汇总)
- Infinite Sequence
- Mysql 和Oracle rows 区别
- 《剑指offer》:[17]调整数组顺序使奇数位于偶数面前
- ppt怎么设置页面比例为4:3
- SQL 语句大全