求解,java
答案:1 悬赏:0 手机版
解决时间 2021-01-25 02:17
- 提问者网友:美人性情
- 2021-01-24 12:31
求解,java
最佳答案
- 五星知识达人网友:佘樂
- 2021-01-24 14:05
public static void main(String[] args) {
int max = 0;
int min = 0;
int count = 0;
while (true) {
System.out.print("请输入一个整数(输入0结束):");
Scanner s = new Scanner(System.in);
int n = s.nextInt();
if (n == 0) {
break;
}
if (count == 0) {
max = n;
min = n;
} else {
if (max < n) {
max = n;
}
if (min > n) {
min = n;
}
}
count++;
}
System.out.println("最大值是:" + max + " 最小值是:" + min);
}
int max = 0;
int min = 0;
int count = 0;
while (true) {
System.out.print("请输入一个整数(输入0结束):");
Scanner s = new Scanner(System.in);
int n = s.nextInt();
if (n == 0) {
break;
}
if (count == 0) {
max = n;
min = n;
} else {
if (max < n) {
max = n;
}
if (min > n) {
min = n;
}
}
count++;
}
System.out.println("最大值是:" + max + " 最小值是:" + min);
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯