该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
回答:
package com.test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Test {
public static void main(String[] args) {
int[] iArray = new int[3];
BufferedReader br = null;
boolean flag = true;
while (flag) {
try {
for (int i = 0; i < iArray.length; i++) {
br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
iArray[i] = Integer.parseInt(str);
}
flag = false;
for (int i = iArray.length; i > 1; i--) {
for (int j = 0; j < iArray.length-1; j++) {
if (iArray[j]>iArray[j+1]) {
int temp = iArray[j];
iArray[j] = iArray[j+1];
iArray[j+1] = temp;
}
}
}
for (int i = 0; i < iArray.length; i++) {
System.out.print(iArray[i] + " ");
}
} catch (Exception e) {
System.out.println("please input number!");
} finally {
try {
if (br != null)
br.close();
} catch (Exception e) {
System.out.println("Running Wrong: ");
e.printStackTrace();
}
}
}
}
}
希望可以帮到你。。。我有问必答。。。望支持。。。