排序算法——选择排序(Selection Sort)
来源:互联网 发布:乐视电视切换网络电视 编辑:程序博客网 时间:2024/06/07 00:43
选择排序(Selection Sort)
C/C++代码:
#include <iostream>#include <stdlib.h>using namespace std;void Print( int r[], int n ){for( int i = 0; i < n; i++ ){cout << r[i] << " ";}cout << endl;}void Swap( int& a, int & b ){int temp = a;a = b;b = temp;}void SelectionSort( int r[], int n ){for( int i = 0; i < n - 1; i++ ){int min = i;for( int j = i + 1; j < n; j++ ){if( r[j] < r[min] ) min = j;}Swap( r[i], r[min] );}}int main(){int r[] = { 34, 12, 45, 78, 52, 18, 67, 90, 64, 72, 27 };int n = sizeof( r ) / sizeof( int );Print( r, n );SelectionSort( r, n );Print( r, n );system( "PAUSE" );return 0;}
0 0
- 选择排序算法——Selection Sort
- 排序算法——选择排序(Selection Sort)
- 排序算法——选择排序(Selection Sort)
- 算法--选择排序 Selection Sort
- 经典排序算法 - 选择排序Selection sort
- 经典排序算法 - 选择排序Selection sort
- 经典排序算法 - 选择排序Selection sort
- 排序算法-选择排序 Selection Sort
- 经典排序算法 - 选择排序Selection sort
- 排序算法---选择排序(Selection Sort)
- 选择排序—简单选择排序(Simple Selection Sort)
- 选择排序—简单选择排序(Simple Selection Sort)
- 选择排序(selection sort)
- 选择排序(Selection Sort)
- selection sort 选择排序
- 选择排序 Selection Sort
- 选择排序(Selection Sort)
- 选择排序(Selection Sort)
- viewstate
- oracle public redo thread and private redo thread
- XMPP协议原理介绍
- 单例的两种创建方式
- 开发成功的oracle数据库
- 排序算法——选择排序(Selection Sort)
- 28 单元测试
- 利用OpenCV的Sobel算子求得图像的梯度信息
- JS删除数组指定对象或者指定下标 删除数组重复值
- vim配置
- Memcached Client Forjava API
- MyISAM 和 InnoDB 讲解
- uc伯克利人工分割图像.seg文件解析
- log4net使用详解