InsertSort(插入排序)
2015-03-28 16:52
399 查看
#include<iostream> using namespace std; void InsertSort( int* array, int n ) { int j, temp; for( int i = 1; i < n; i++ ) { temp = array[i]; j =i - 1; while( array[j] > temp && j >= 0) { array[j+1] = array[j]; j--; } array[j+1] = temp; } } void OutPut( int* array, int n ) { for( int i = 0; i < n; i++ ) { cout<<array[i]<<" "; } cout<<endl; } int main() { const int N = 10; int a = {13,2,4,16,336,3,8,9,10,11}; OutPut( a, N); InsertSort( a, N); OutPut( a, N); return 0; }
相关文章推荐
- 插入排序(InsertSort)
- Java基础知识强化54:经典排序之插入排序(InsertSort)
- 插入排序(I)Insert Sort
- 内部排序之插入排序(InsertSort)
- 插入排序 (Insert Sort)
- 插入排序(1)——直接插入排序(insert sort)
- 插入排序(Insert Sort)
- 插入排序(InsertSort)
- InsertSort(插入排序)
- 数据算法之插入排序(insertSort)的Java实现
- 插入排序(insert sort)
- Thinking in Insert Sort(插入排序)
- 排序1+2:交换排序(ExchangeSort),选择排序(SelectSort)和插入排序(Insertsort)
- InsertSort 插入排序
- 数据算法之插入排序(insertSort)的Java实现
- 经典排序算法 INSERT-SORT: 插入排序
- c++算法联系,冒泡排序,bubble sort,插入排序,insert sort,
- 算法学习----->Insertsort(插入排序)
- 插入排序(insertSort)
- (直接)插入排序(Insert Sort)