直接插入排序
来源:互联网 发布:三维全景漫游软件 编辑:程序博客网 时间:2024/06/09 18:34
//============================================================================
// Name : C++Study.cpp
// Author : pan
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <assert.h>
#include <string.h>
using namespace std;
void zj_sort(int a[], int n) {
for (int i = 1; i < n; i++)
for (int j = 0; j < i; j++) {
if (a[i] < a[j]) {
int temp=a[i];
for (int k = i; k > j; k--) {
a[k] = a[k - 1];
}
a[j] = temp;
break;
}
}
}
int main() {
int a[5] = { 2, 4, 1, 3, 5 };
zj_sort(a, 5);
for (int i = 0; i < 5; i++)
cout << a[i];
return 0;
}
// Name : C++Study.cpp
// Author : pan
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <assert.h>
#include <string.h>
using namespace std;
void zj_sort(int a[], int n) {
for (int i = 1; i < n; i++)
for (int j = 0; j < i; j++) {
if (a[i] < a[j]) {
int temp=a[i];
for (int k = i; k > j; k--) {
a[k] = a[k - 1];
}
a[j] = temp;
break;
}
}
}
int main() {
int a[5] = { 2, 4, 1, 3, 5 };
zj_sort(a, 5);
for (int i = 0; i < 5; i++)
cout << a[i];
return 0;
}
0 0
- 插入排序--直接插入
- 插入排序------直接插入
- 插入排序---直接插入
- 排序:直接插入排序
- 排序---直接插入排序
- 排序 -- 直接插入排序
- 排序---直接插入排序
- 排序--直接插入排序
- 排序-直接插入排序
- 【排序】直接插入排序
- 排序--直接插入排序
- 排序:直接插入排序
- 【排序】直接插入排序
- 排序--直接插入排序
- 排序--直接插入排序
- 排序-直接插入排序
- 插入排序--直接插入排序
- 插入排序-直接插入排序
- 基于SpringMVC的web应用的ContextLoaderListener与DispatcherServlet标准组合配置
- hibernate expecting IDENT, found '*' 怎么解决?
- morphia与spring的整合
- Core Animation 基本动画效果汇总
- android开发——从相册中选择图片不裁剪
- 直接插入排序
- 图像处理和图像识别中常用的OpenCV函数
- SQLPLUS常用命令
- LATCH: Learned Arrangements of Three Patch Codes
- java学习之城市包围农村
- TCP状态迁移
- 我的技术波克开通啦
- 九度oj 1000
- Android Fragment 真正的完全解析