/*
* 用Scanner接受用户输入并进行冒牌排序后输出
*/
package test1;
import java.util.Scanner;//引入扫描控制台输入函数
public class test1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in); //创建Scanner
/*
* 接受用户输入一字符串,再将其转化为整型数组
*/
String s = sc.nextLine();//将用户输入的一整行字符串赋给s
String[] c = s.split(“\s+”);//用空格将其分割成字符串数组
int size = c.length;
int[] b =new int[size];
for (int m = 0; m < b.length; m++) {
b[m] = Integer.parseInt(c[m]);
}
/*
* 进行冒泡排序
*/
int temp=0;
for (int i = 0; i < b.length; i++) {
for (int j = 0; j < b.length-i-1; j++) {
if(b[j]>b[j+1]){
temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
/*
* 输出排序后的数组
*/
for(int n = 0; n < b.length ; n++){
System.out.print(b[n]);
System.out.print(' ');
}
sc.close();
}
}