标签:java for ar new public print class string
/** * 冒泡排序 * @author fgtian * */ public class BubleSort { public static void sort(int[] arr) { int length = arr.length; for (int i = 0; i < length; i++) { for (int j = length - 1; j > i; j--) { int num1 = arr[j]; int num2 = arr[j - 1]; if (num2 > num1) { arr[j - 1] = num1; arr[j] = num2; } } } } public static void main(String[] args) { int len = 10; int[] arr = new int[len]; Random r = new Random(); for (int i = 0; i < len; i++) { arr[i] = r.nextInt(100) - 50; } sort(arr); for (int i = 0; i < len; i++) { System.out.print(" " + arr[i]); } } }
标签:java for ar new public print class string
原文地址:http://blog.csdn.net/buleriver/article/details/38470045