选择排序
来源:互联网 发布:庭院流水桌面软件 编辑:程序博客网 时间:2024/06/06 21:41
#include <iostream>#include <cstdlib>using namespace std;/* * name : selection sort * author : sangoly * O(n^2) * S(1) * date : 2014/4/15 */void selection_sort(int a[], int length){ for (int i=0; i<length-1; i++) { int smallest = i; for (int j=i+1; j<length; j++) if (a[j] < a[smallest]) { int tmp = a[smallest]; a[smallest] = a[j]; a[j] = tmp; } }}int main(int argc, const char **argv){ int a[] = {3, 41, 52, 26, 38, 57, 9, 49}; selection_sort(a, 8); for (int i=0; i<8; i++) cout<<a[i]<<" "; cout<<endl; system("pause"); return 0;}
0 0
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序:
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- 选择排序
- error C2065: 'IDD_DIALOG1' : undeclared identifier
- jpype,jpython调用jar包中jdk的问题.
- JAR、WAR、EAR的使用和区别
- XML DOM遍历节点树
- NDAP 日志
- 选择排序
- ear包和war包的文件组织结构及制作方法
- 关于service
- Notification 和 NotificationManager 的基本用法
- HDU 1172 猜数字(暴力枚举)
- Android支持多屏幕(6)dp转换成px
- “微信”与“来往”之争:消费者成最终获益人
- 只为重新出发
- 在Spring 2.0中集成AspectJ