//基本上在这个程序中,你必须向用户询问一个终止值,然后是一组数字。当您输入您的终止号码时,程序结束。然后,您输出您输入的数字的最大值和最小值,但不是终止值。我正在为我的 for 语句寻求帮助,因为循环只运行了两次。请只有 IO。
public class smalllargest {
public static void main(String[] args) {
System.out.println("Enter any number, then re-enter that number when you wish to be done.");
int t = IO.readInt();
System.out.println("Enter your set of numbers");
int s = IO.readInt();
int max = s;
int min = s;
for(int i = 0; i!=t; i++) {
int n = IO.readInt();
if(n > max) {
max = n ;
}
if(n< max) {
min = n;
}
if(n == t){
break;
}
System.out.println("max:");
IO.outputIntAnswer(max);
System.out.println("min:");
IO.outputIntAnswer(min);
}
}
}