插入排序InserSort
来源:互联网 发布:c语言程序流程图软件 编辑:程序博客网 时间:2024/06/15 15:08
#include <iostream>
using namespace std;
void InsertSort(int a[], int length)
{
int n = length;
int key;
for (int j = 1; j < n; j++)
{
key = a[j];
int i = j - 1;
while (i > 0 && a[i] > key)
{
a[i + 1] = a[i];
i = i - 1;
}
a[i+1] = key;
}
}
int main()
{
int n,i;
int a[100];
cout << "Please input the number of array : ";
cin >> n;
cout << "Please input the array : ";
for (i = 0; i < n; i++)
cin >> a[i];
InsertSort(a, n);
cout << "The array after insertsort is :" << endl;
for (i = 0; i < n; i++)
cout << a[i] << " ";
system("pause");}
0 0
- 插入排序(InserSort)
- 插入排序InserSort
- InserSort
- 插入排序-【插入排序】
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 插入排序
- 如果快速接手一个复杂的系统
- ListBox拖拽Item项到TreeView
- 易语言调用GetPrivateProfileStringA
- 【Light】[1294]Positive Negative Sign
- IntelliJ IDEA快捷键总结
- 插入排序InserSort
- JDBC初识
- 关于类型转换、溢出、移位等操作的小总结
- 百度地图打标展示地点分布图 ,如何利用百度地图API进行标注
- (转)cocoapods使用教程
- codeforces 608B Hamming Distance Sum
- java判断string变量是否是数字的六种方法小结
- LeetCode Merge k Sorted Lists 归并
- Eeny Meeny Moo(约瑟夫环)