String s = "25 11 -6 20 102 9";
String[] st = s.split(" ");
int t = 0;
int[] arr = new int[st.length];
for (String string : st) {
arr[t++] = Integer.parseInt(string);
}
for (int i = 0; i < arr.length - 1; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i] > arr[j]) {
arr[i] = arr[j] ^ arr[i] ^ (arr[j] = arr[i]);
}
}
}
StringBuffer sb = new StringBuffer();
for (int i : arr) {
sb.append(i + " ");
}
sb.deleteCharAt(sb.length() - 1);
String str = new String(sb);
System.out.println(str);
}
|