如何以相反的顺序打印200到150的数字,并使用单个while循环按顺序打印200到150的数字?
class test {
public static void main(String[]args) {
while(n>=150) {
System.out.println(n);
n--;
}
n=0;
while(n<=150) {
System.out.println(n);
n++;
}
}
}
答案 0 :(得分:-1)
你走了:
public static void main(String[] args) {
int n = 150;
while(n <= 200) {
System.out.println("Decreasing : " + (150 + (200 - n)));
System.out.println("Increating : " + (n++));
}
}