Java冒泡排序
package com.lanxi.demo4; import java.util.Random; public class Maopao { public static void main(String[] args) { Random r=new Random(); int[] num=new int[7]; for (int i = 0; i < num.length; i++) { num[i]=r.nextInt(10); } for (int i = 0; i < num.length-1; i++) { for (int j = 0; j < num.length-i-1; j++) { if (num[j]>num[j+1]) { int team=num[j]; num[j]=num[j+1]; num[j+1]=team; } } } for (int i = 0; i < num.length; i++) { System.out.print(num[i]+" "); } } }
时间最会骗人,但也能让你明白,这个世界上没有什么是不能失去的,留下的尽力珍惜,得不到的都不重要