就是在dos窗口里键入信息时(是字符串数组吧),要注意什么问题呢,就是具体格式是怎样的呢?
public class SortOrder {
public static void main(String args[]) {
int[] a = new int[args.length];
for (int i = 0; i < args.length; i++) {
a[i] = Integer.parseInt(args[i]);
}
sortNum(a);
for (int i = 0; i < a.length; i++) {
System.out.print(a[i] + " ");
}
}
private static void sortNum(int[] a) {
for (int i = 0; i < a.length; i++) {
for (int j = i + 1; j < a.length; j++) {
if (a[j] < a[i]) {
int t = a[j];
a[j] = a[i];
a[i] = t;
}
}
System.out.print(a[i] + " ");
}
}
}
|
|