获取最低价手机价格--0703

时间:2022-07-20 18:08:17

代码:

import java.util.Scanner; public class Work03 { static Scanner input = new Scanner(System.in); public static void main(String[] args) { int[] price = new int[4]; System.out.println("请输入4家店的价格"); System.out.print("第1店的价格:"); price[0] = input.nextInt(); int min = price[0]; for(int i = 1;i<price.length;i  ) { System.out.print("" (i 1) "店的价格:"); price[i] = input.nextInt(); if(price[i]<min) { min = price[i]; } } System.out.println("最低价格是:" min); } }

运行结果:

获取最低价手机价格--0703