数据结构:直接排序法 C++
来源:互联网 发布:win8安装软件乱码 编辑:程序博客网 时间:2024/06/14 23:56
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include <array>
#include <sstream>
using namespace std;
void insert_sort(int a[], int n)
{
int j, i, temp;
//精髓,抽牌的法
for (i = 0; i < n; i++)
{
temp = a[i];
for (j = i - 1; j >= 0 && temp < a[j]; j--)
{
a[j + 1] = a[j];
}
a[j + 1] = temp;
}
}
void print_arrary(int a[], int len)
{
int i;
for (i = 0; i < len; i++)
{
cout << a[i] << "";
}
cout << endl;
}
int main(int argc, int *argv[])
{
int a[] = { 7,3,5,8,9,1,2,4,6 };
print_arrary(a, 9);
insert_sort(a,9);
print_arrary(a, 9);
getchar();
return 0;
}
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include <array>
#include <sstream>
using namespace std;
void insert_sort(int a[], int n)
{
int j, i, temp;
//精髓,抽牌的法
for (i = 0; i < n; i++)
{
temp = a[i];
for (j = i - 1; j >= 0 && temp < a[j]; j--)
{
a[j + 1] = a[j];
}
a[j + 1] = temp;
}
}
void print_arrary(int a[], int len)
{
int i;
for (i = 0; i < len; i++)
{
cout << a[i] << "";
}
cout << endl;
}
int main(int argc, int *argv[])
{
int a[] = { 7,3,5,8,9,1,2,4,6 };
print_arrary(a, 9);
insert_sort(a,9);
print_arrary(a, 9);
getchar();
return 0;
}
0 0
- 数据结构c语言版之直接插入排序
- 数据结构 C语言实现直接插入排序
- 数据结构:直接排序法 C++
- 数据结构 - 直接插入排序法
- {数据结构}直接插入排序
- 数据结构--直接插入排序
- 【数据结构】直接插入排序
- 数据结构---直接插入排序
- 数据结构-直接选择排序
- 数据结构-直接插入排序
- 数据结构:直接插入排序
- 【数据结构】直接插入排序
- 数据结构----直接插入排序
- 数据结构--直接插入排序
- [数据结构]直接插入排序
- 数据结构---直接插入排序
- 数据结构 直接插入排序
- 数据结构直接插入排序
- Android学习-menu无法显示的问题
- Spark StringIndexer and IndexToString usage
- css笔记(带补充)
- FlycoDialog 可直接用的三方Dialog
- 字符串函数的实现(第二波)
- 数据结构:直接排序法 C++
- php正则表达式的小点心
- Oracle中表空间和数据文件的理解--so easy,妈妈再也不用担心我的学习!
- iOS十六进制颜色转换成UIColor
- 【LeetCode】167. Two Sum II - Input array is sorted
- Java类成员变量、普通成员变量、初始化块、构造方法的初始化和执行顺序
- 13.shell编程(13) --- 文件系统
- springmvc项目启动报错:'sessionFactory' or 'hibernateTemplate' is required
- UVA 1629 Cake slicing