我正在尝试从输入序列中获取最大和最小ODD数,而不使用数组,请告知我应该添加什么,我正在使用以下代码:
System.out.print("Enter odd integers(even to Stop): " );
do {
num = input.nextInt();
sum += num;
} while (num % 2 != 0);
if (num < min) {
min = num;
}
if (num > max) {
max = num;
}
System.out.print("Minimum Odd Number: " + min + ";");
System.out.println("Maximum Odd Number: " + max);
System.out.print("Sum: " + sum);
慕田峪4524236
相关分类