package chp1;import javax.swing.JOptionPane;public class Chp3 { static int MIN(int x, int y){ int min=0; if(x>y) min=y; else min=x; return min; } public static void main(String[] args){ int num1; int num2; int time; int i=1; int min=0; time = Integer.parseInt(JOptionPane.showInputDialog("输入的个数:")); num1=Integer.parseInt(JOptionPane.showInputDialog("输入第"+i+"个数:")); for(;i<time;i++){ num2=Integer.parseInt(JOptionPane.showInputDialog("输入第"+(i+1)+"个数:")); min = MIN(num1,num2); } JOptionPane.showMessageDialog(null, "最小值为"+min); }}
1 回答
已采纳
望远
TA贡献1017条经验 获得超1032个赞
time = Integer.parseInt(JOptionPane.showInputDialog("输入的个数:")); num1=Integer.parseInt(JOptionPane.showInputDialog("输入第"+i+"个数:")); for(;i<time;i++){ num2=Integer.parseInt(JOptionPane.showInputDialog("输入第"+(i+1)+"个数:")); num1 = MIN(num1,num2); } JOptionPane.showMessageDialog(null, "最小值为"+num1);
这样就行了
添加回答
举报
0/150
提交
取消