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);
}
}
望远
相关分类