编写一个用户界面的程序,接受输入的10个整数,并输出这是个整数的最大值盒最小值

codes23457789 codes23457789 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
代码如下:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Max_Min {
public static void main(String[] args) {
int i,n = 10,max = 0,min = 0,temp = 0;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

max=min=Integer.parseInt(br.readLine());

} catch (IOException e) { }
for(i =2;i<=n;i++) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
temp = Integer.parseInt(br.readLine());
if(temp>max)max=temp;
if(temp<min)min=temp;
} catch (IOException e) {}
}
System.out.println("max=" +max+"\\nmin="+min);
}

}

怎么就数不结果了,请高手讲解!
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
codes23457789
Java SE 62,621 成员 307,251 内容