地精排序
来源:互联网 发布:c语言考试题库 编辑:程序博客网 时间:2024/05/16 01:26
#include <iostream>
using namespace std;
void gnome_sort(int narray[], int nCount)
{
for (int i = 0; i < nCount;)
{
if (0 == i||narray[i-1]<=narray[i])
{
i++;
}
else
{
swap(narray[i - 1], narray[i]);
i--;
}
}
}
int main(int argc, char **argv)
{
int Array[] = {6,5,3,1,8,6,12,0};
gnome_sort(Array, 8);
for (int i = 0; i < 8; i++)
{
cout << Array[i] << endl;
}
}
using namespace std;
void gnome_sort(int narray[], int nCount)
{
for (int i = 0; i < nCount;)
{
if (0 == i||narray[i-1]<=narray[i])
{
i++;
}
else
{
swap(narray[i - 1], narray[i]);
i--;
}
}
}
int main(int argc, char **argv)
{
int Array[] = {6,5,3,1,8,6,12,0};
gnome_sort(Array, 8);
for (int i = 0; i < 8; i++)
{
cout << Array[i] << endl;
}
}
0 0
- 地精排序
- 地精排序
- 地精排序
- 【基础排序】地精排序
- 地精排序初探
- 地精排序Gnome Sort
- 地精排序-Gnome Sort
- 排序算法之地精排序
- 再探地精排序GnomeSort
- 经典排序算法 - 地精排序Gnome Sort
- 经典排序算法 - 地精排序Gnome Sort
- 地精排序Gnome Sort ----(排序算法十)
- 经典排序算法 - 地精排序Gnome Sort
- 地精排序(Gnome Sort) 最简单的排序算法
- java排序算法_008地精排序(Gnome Sort)
- 基础算法系列(十三)排序算法之地精排序
- 数据结构&算法实践—【排序|交换排序】地精排序及改进
- 地精排序和桶式排序——为什么我们要学算法
- tomcat加虚拟路径
- 12月15日做图书管理系统所遇到的问题
- Android adjustresize全屏无效问题
- 安卓笔记之BroadcastReceiver广播
- 微信HTML5小游戏之超级玛丽
- 地精排序
- android在项目中如果只需要一种cpu架构的处理方法
- 【Egret】使用VSCode 编译,断点调试Egret项目
- cdh5.8.3安装过程中问题解决方法Error loading MySQLdb和No portmap or rpcbind service
- WEB漏洞 关于%00的传参空格漏洞
- 解决index.lock 的办法
- 在oracle数据库中插入含有&符号的字符串
- angularjs系列之轻松使用$q进行异步编程与拦截器
- Oracle数据库,唯一标识ID的生成