希尔排序
来源:互联网 发布:无线信号强度测试软件 编辑:程序博客网 时间:2024/06/05 04:19
/* * Copyright 2014 YU Heng-yang. All rights reserved. * * shell_sort.c - Simple shell sort implementation. * * 2014-7-5 YU Heng-yang. */#include <stdio.h>#include "common.h"#include <assert.h>void shell_sort(int *arr, int n);int main(int argc, char *argv[]){int *array, n; n = input(&array);shell_sort(array, n);output(array, n);return 0;}void shell_sort(int *arr, int n){int inc, i, j, temp;assert(arr);/* you may consider another increment sequence */for (inc = n / 2; inc > 0; inc /= 2) {for (i = inc; i < n; i += inc) {temp = arr[i];for (j = i; j >= inc && temp < arr[j - inc]; j -= inc)arr[j] = arr[j - inc];arr[j] = temp;}}}
0 0
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- 希尔排序
- jquery.cookie使用方法
- <xliff:g>标签
- 编写高效的Android代码
- 启动eclipse提示找不到虚拟机解决办法
- 网络流学习笔记
- 希尔排序
- Linux SFTP详解
- IO流知识点整理
- directory not found for option
- java 猜拳游戏代码
- Apache与Tomcat的区别 ,几种常见的web/应用服务器
- 字符串读取
- Т-prime http://codeforces.com/problemset/problem/230/B
- Visual Studio2010调试WEB项目默认浏览器