package exercise; import java.util.Arrays; import java.util.Scanner; import javax.swing.plaf.synth.SynthStyle; public class Exe2_Maopao { public static void main(String[] args) { int temp; //交换数据用 int[] Price = new int[4]; //定义数组 Scanner input = new Scanner(System.in); //输入数据 for (int i = 0 ;i < 4; i++){ System.out.println("第"+(i+1)+"店价格:"); Price[i] = input.nextInt(); } //执行轮数 int k; for (int j = 0;j < 4; j++){ //执行一轮结果 for(k = 0; k < 4-j-1; k++){ if(Price[k] < Price[k+1] ){ temp = Price[k]; Price [k] = Price [k+1]; Price [k+1] = temp; } } //输出每一轮的最小数 System.out.print(Price[k]+" "); } System.out.println(" 最低价格是:"+Price[3]); input.close(); } }