易截截图软件、单文件、免安装、纯绿色、仅160KB

java:三种经典大排序汇总,冒泡,插入,选择

package arrays.myArray;
public class SortArr {
 public static void main(String[] args) {
  int[] arrInt = { 4, 7, 8, 5, 6, 3, 2, 3, 4 };
  maoPaoSort(arrInt);
  print("冒泡排序:", arrInt);
  arrInt = new int[]{ 4, 7, 8, 5, 6, 3, 2, 3, 4 };
  insertSort(arrInt);
  print("插入排序:", arrInt);
  arrInt = new int[]{ 4, 7, 8, 5, 6, 3, 2, 3, 4 };
  checkSort(arrInt);
  print("选择排序:", arrInt);
 }
 // 冒泡排序
 private static void maoPaoSort(int[] arrInt) {
  int temp = 0;
  for (int i = 0; i < arrInt.length; i++) {
   for (int j = 0; j < arrInt.length - 1; j++) {
    if (arrInt[i] < arrInt[j]) {
     temp = arrInt[i];
     arrInt[i] = arrInt[j];
     arrInt[j] = temp;
    }
   }
  }
 }
 // 插入排序
 private static void insertSort(int[] arrInt) {
  //倒数第二个开始比较
  for (int i = arrInt.length - 2; i >= 0; i--) {
   int j = 0;
   for (j = arrInt.length - 1; j > i; j--) {
    if (arrInt[i] > arrInt[j]) {
     break;
    }
   }
   int temp = arrInt[i];
   for (int k = i; k < j; k++) {
    arrInt[k] = arrInt[k + 1];
   }
   arrInt[j] = temp;
  }
  
  //正数第二个开始比较
  /*for (int i = 1; i < arrInt.length; i++) {
   int j = 0;
   for (j = 0; j < arrInt.length - 1; j++) {
    if (arrInt[i] > arrInt[j]) {
     break;
    }
   }
 &nbs


相关文档:

Java中集合容器类List和Set的用法

List的用法
List包括List接口以及List接口的所有实现类。因为List接口实现了Collection接口,所以List接口拥有Collection接口提供的所有常用方法,又因为List是列表类型,所以List接口还提供了一些适合于自身的常用方法,如表1所示。
表1  List接口定义的常用方法及功能
从表1可以看出,List接口提供的适合于自身的 ......

Java初学者:图书管理小工具代码

1.Welcome.java
import java.util.Date;
import java.util.Scanner;

public class Welcome {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args){
// TODO Auto-generated method stub

System.out.println("Welcome to vis ......

java 根据两点经纬度来算距离

package com.njty.util;
public class Test {
  private static final double EARTH_RADIUS = 6378137;
  private static double rad(double d)
     {
        return d * Math.PI / 180.0;
     }
     ......

中国公历算法&中国农历算法(JAVA)

中国公历算法不是太难,关键是星期值的确定。这里给出了简单算法: 
public static int dayOfWeek(int y, int m, int d) {
int w = 1; // 公历一年一月一日是星期一,所以起始值为星期日
y = (y-1)%400 + 1; //&n ......

java:手写MyLinkedList所有方法,增删改查

package arrays.myArray;
public class MyLinkedList {
 private int size = 0;
 private Node1 head = null;
 // 添加
 public void add(Object obj) {
  add(size, obj);
 }
 // 修改
 public void add(int index, Object obj) {
  if (null == head) ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号