请阅读下面的程序
public class Test {
public static void main(String[] args) {
int x;
int y;
for (x = 1, y = 1; x <= 100; x++) {
if (y >= 20) {
break;
}
if (y % 3 == 1) {
y += 3;
continue;
}
y -= 5;
}
System.out.println(“x=” + x + “,y=” + y);
}
}
下列选项中,哪一个是程序的运行结果( )
public class Test {
public static void main(String[] args) {
int x;
int y;
for (x = 1, y = 1; x <= 100; x++) {
if (y >= 20) {
break;
}
if (y % 3 == 1) {
y += 3;
continue;
}
y -= 5;
}
System.out.println(“x=” + x + “,y=” + y);
}
}
下列选项中,哪一个是程序的运行结果( )
举一反三
- using System; class Test { public static void Main() { int x = 5; int y = x++; Console.WriteLine(y); y=++x; Console.WriteLine(y); } }
- 写出以下程序的运行结果。using System;class Test{public static void Main(){int x = 5;int y = x++;Console.WriteLine(y);//第1空y=++x;Console.WriteLine(y);//第2空}}
- 1. 写出以下程序的运行结果。 class Test { public static void Main() { int x = 5; int y = x++; Console.WriteLine(y); y=++x; Console.WriteLine(y); Console.WriteLine(x); } } 运行结果:
- (6-6)请阅读程序,写出程序运行结果。 class Test{ static int x=10; int y=99; { y=y+10; } static { x=x+5; } { y=y+10; } static { x=x+5; } public Test() {//构造方法 x=x+5; } { System.out.println(x*y); } } public class Demo11 { public static void main(String[] args) { Test t1=new Test(); Test t2=new Test(); } }
- 写出下面程序运行结果。public class Demo public static void main(String args[]) int x = 5, y = 10, r = 5 switch (x y) case 15: r = x case 20: r -= y case 25: r = x / y default: r = r System.out.println(r)