📄 ch3_e3_10.java
字号:
import java.io.*;
public class ch3_e3_10
{
public static void main(String args[])
{
int max=0, min=0, value=0;
for (int i=1; i<=10; i++)
{
try{
System.out.println("输入第" + i + "个整数:");
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
value = Integer.parseInt(s);
if(i==1)
{
max=min=value;
}
else
{
max = value>max ? value : max;
min = value<min ? value : min;
}
}
catch(NumberFormatException enf)
{
System.out.println("整数格式输入错误,请重新输入。\n");
i--;
}
catch(IOException ioe)
{
System.out.println("一般输入输出错误,程序终止。");
System.exit(0);
}
}// end of for
System.out.println("最大数为:" + max);
System.out.println("最小数为:" + min);
}// end of method
}// end of class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -