package replace; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Scanner; /** * 冒泡排序 */ public class test { public static void main(String[] args) { String s = new Scanner(System.in).next(); String[] split = s.split(","); int[] arr = new int[split.length]; for (int i = 0; i < split.length; i++) { arr[i]=Integer.parseInt(split[i]); } // //控制台输入三个数字,回车 // arr[0] = new Scanner(System.in).nextInt(); // arr[1] = new Scanner(System.in).nextInt(); // arr[2] = new Scanner(System.in).nextInt(); for (int i=0 ;i< arr.length-1 ;i++) { for (int j = 0; j < arr.length-1-i; j++) { //从大到小排序 //从小到大排序只需要改变下符号即可 if(arr[j]>arr[j+1]){ int temp = arr[j]; arr[j]=arr[j+1]; arr[j+1] = temp; } } } for (int i = 0; i < arr.length; i++) { System.out.print(arr[i] +" "); } }