zoukankan
html css js c++ java
shell sort
#include <iostream> template <class elem> void swap(elem a[], int p1, int p2) { elem tmp = a[p1]; a[p1] = a[p2]; a[p2] = tmp; } template <class elem> void print(elem a[], int length) { for (int i = 0; i < length; i++) std::cout << a[i] << ' '; std::cout << std::endl; } template <class elem> void insert_sort(elem a[], int length, int increment) { for (int i = increment; i < length; i += increment) for (int j = i; j >= increment; j -= increment) if (a[j] < a[j-increment]) swap(a, j, j - increment); } template <class elem> void shell_sort(elem a[], int length) { for (int i = length/2; i > 2; i/= 2) for (int j = 0; j < i; j++) insert_sort(&a[j], length - j, i); insert_sort(a, length, 1); } int main(void) { int a[] = {42, 20, 17, 13, 28, 14, 23, 15}; print(a, 8); shell_sort(a, 8); print(a, 8); system("pause"); return 0; }
查看全文
相关阅读:
【REACT HOOKS】useState是如何保存并更新数据的?
CSS Modules 使用
【TS】一些常用的工具类型
【TS】type和interface的区别
【TS】unknown类型
判断虚拟导航栏(NavigationBar)是否显示
本地的FTP服务器
Cocos2d-x3.3RC0的Android编译Activity启动流程分析
Eclipse/MyEclipse 最最常用的快捷键
anroidstudio log
原文地址:https://www.cnblogs.com/seebro/p/2476549.html
最新文章
aiohttp的模板
python从Excel中提取邮箱
爬虫的日志,只存7天的日志
Scrapy-Redis 空跑问题,redis_key链接跑完后,自动关闭爬虫
第十一讲:集合
第九讲:字典
第八讲:元组
第七讲:列表
第六讲:函数(下)
第五讲:函数(上)
热门文章
第四讲:控制流:条件语句
第三讲:字符串类型判断与转换
第二讲:编码详解,防止中文乱码
navicat for mysql破解
手机连接fiddler无网络
useEffect和useLayoutEffect执行时机
【react hooks】--初渲染和更新阶段
【webpack】热更新
【webpack】初始化、构建、生成
【GIT】rebase -- 与merge的区别,合并多次commit
Copyright © 2011-2022 走看看