2 Star 0 Fork 0

CS-IMIS-23/why20172321

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gapSort.java 727 Bytes
一键复制 编辑 原始数据 按行查看 历史
N-idhogg 提交于 7年前 . 间隔排序法和测试
package week6;
public class gapSort {
private static <T extends Comparable<T>>
void swap(T[] data, int index1, int index2) {
T temp = data[index1];
data[index1] = data[index2];
data[index2] = temp;
}
public static <T extends Comparable<T>>
void gapSort(T[] data) {
int position, scan;
T temp;
int i = 4;
while (i >= 1) {
for (position = data.length - 1; position >= 0; position--) {
for (scan = 0; scan < data.length - i; scan++) {
if (data[scan].compareTo(data[scan + i]) > 0)
swap(data, scan, scan + i);
}
}
i -= 2;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/CS-IMIS-23/why20172321.git
git@gitee.com:CS-IMIS-23/why20172321.git
CS-IMIS-23
why20172321
why20172321
master

搜索帮助