标签:
package lianxi; import java.util.*; public class Maopaopaixu { public static void main(String[] args) { //输入数字 并把数字插入数组中 Scanner shu=new Scanner(System.in); System.out.println("请输入10个数字:"); int ary[]=new int[10]; for (int i = 0; i < 10; i++) { int b = shu.nextInt(); ary[i]=b; } //显示一下数组中的元素 看是否与输入对应 for (int i = 0; i <ary.length; i++) { System.out.print("ary["+i+"]="+ary[i]+" "); } System.out.println(); //从大到小排序 每循环一次输出ary[j]-ary[9]的最大值 for (int j = 0; j < 10; j++) { for (int k = j; k <9; k++) { if(ary[j]<ary[k+1]) { int m=0; m=ary[j]; ary[j]=ary[k+1]; ary[k+1]=m; } } System.out.print(ary[j]+" "); } } }
标签:
原文地址:http://www.cnblogs.com/wenwen123/p/5477203.html