import java.util.Arrays;
import java.util.Random;
public class SortSequence{
public static void main(String[] args){
Random rd=new Random(); //利用随机数随意产生15个0~20之间的随机数
int[] array=new int[15];
System.out.println("original number group:");
for(int i=0;i<array.length;i++){
array[i]=rd.nextInt(20);
System.out.print(" "+array[i]);
if((i+1)%5==0)
System.out.println();
}
Arrays.sort(array);
System.out.println("sorted:");
for(int i=0;i<array.length;i++)
{
System.out.print(" "+array[i]);
if((i+1)%5==0)
System.out.println();
}
}
}
时间: 2024-10-10 23:00:32