Unable to read from monitor: Connection reset by peer
2015-06-26 10:07
507 查看
/** * TODO */ package com.xeezee.sort; /** * 选择排序 * * @author luoqinglong * @date 2012-7-31 */ public class ChooseSort { private final long[] origArr = new long[] { 12, 65, 2, 33, 89, 23, 10 }; private final static int SORT_DEST = 0; private final static int SORT_ASC = 1; /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub ChooseSort chooseSort = new ChooseSort(); chooseSort.sort(chooseSort.origArr, ChooseSort.SORT_ASC); for (int j = 0; j < chooseSort.origArr.length; j++) { System.out.println(chooseSort.origArr[j]); } } public void sort(long[] arrays, int sortType) { int len = this.origArr.length; for (int i = 0; i < len; i++) { // 从左往右比较 int destIndex = i; for (int j = i; j < len - 1; j++) { if (sortType == ChooseSort.SORT_DEST) { if (this.origArr[destIndex] < this.origArr[j + 1]) { // this.swap(i, j + 1); destIndex = j + 1; } } else { if (this.origArr[destIndex] > this.origArr[j + 1]) { // this.swap(i, j + 1); destIndex = j + 1; } } } this.swap(i, destIndex); } } public void swap(int leftInde, int rightIndex) { long temp = this.origArr[leftInde]; this.origArr[leftInde] = this.origArr[rightIndex]; this.origArr[rightIndex] = temp; } }
相关文章推荐
- 谈谈互联网圈内幕交易的那些事儿
- “大型售票系统”和“真正的电商系统”在“库存”巨大的差异计算
- 秒杀多线程第一篇 多线程笔试面试题汇总
- jquery统计页面的pv/ip及停留时间等
- oracle dblink调用函数
- 二、Android应用的界面编程(七)ViewAnimator及其子类[ ViewSwitcher、ImageSwitcher、TextSwitcher、ViewFlipper ]
- 设计模式-------------建造者模式(生成器模式)
- html5放大缩小
- C++并发编程概述——关于并行编程分布式编程
- Egret之egret.gui.List的使用教程
- leetcode Combination Sum II回溯问题
- Android中Service与IntentService的使用比较
- Android中Service与IntentService的使用比较 2015-06-26 10:06 6人阅读 评论(0) 收藏
- [转]oracle中查询指定行数的记录
- 电脑全屏雪花飘落的背景特效
- Win10 手机预览版10149简单快速上手体验视频
- Java生成csv文件时,数字格式为“0001”,用excel打开时,变为“1”的解决方法
- Agilla中间件-mobile agent
- 黑马程序员——银行业务调度系统
- JVM系列文章(一):Java内存区域分析