易截截图软件、单文件、免安装、纯绿色、仅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初学者:图书管理小工具代码

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串口编程2

    再次从网上查询,搜到了RXTXcomm.jar包比较好,是封装了comm.jar的方法。
    安装:
    1.copy rxtxSerial.dll to [JDK-directory]\jre\bin\rxtxSerial.dll
    2.copy RXTXcomm.jar to [JDK-directory]\jre\lib\ext\RXTXcomm.jar
  &nbs ......

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中文乱码解决总结


为什么说乱码是中国程序员无法避免的话题呢?这个首先要从编码机制上说起,大家都是中文和英文的编码格式不是一样,解码也是不一样的!如果中国的程序员不会遇到乱码,那么只有使用汉语编程。汉语编程是怎么回事我也不大清楚,应该是前年吧,我一朋友给我介绍汉语编程,怎么不错不错?当时因为学习忙没去关注这个,等我闲 ......

java:手写二叉树BinaryTree添加和查询方法

package arrays.myArray;
public class BinaryTree {
 private Node root;
 // 添加数据
 public void add(int data) {
  // 递归调用
  if (null == root)
   root = new Node(data, null, null);
  else
   addTree(root, data);
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号