题目内容

请阅读下面的程序public class Test {public static void main(String[] args) {int a[] = {2,0,4,1,8,3,5};int temp;for (int i = 0; i < a.length - 1; i++) {for (int j = a.length - 1; j > i; j--) {if (a[j] < a[j - 1]) {temp = a[j];a[j] = a[j - 1];a[j - 1] = temp;}}}for (Integer i : a) {System.out.println(i);}}}下列选项中,哪一个是程序的运行结果:

A. 8,5,4,3,2,1,0
B. 5,3,8,1,4,0,2
C. 2,0,4,1,8,3,5
D. 0,1,2,3,4,5,8

查看答案
更多问题

请阅读下面的程序public class Test {public static void main(String[] args) {int temp = 0;for (int i = 1; i < 5; i++) {for (int j = 0; j < i; j++) {temp++;}}System.out.println(temp);}}下列选项中,哪个是程序的运行结果:

A. 5
B. 9
C. 10
D. 15

请阅读下面的程序public class Test {public static void main(String[] args) {int temp = 0;for (int i = 1; i < 5; i++) {for (int j = 0; j < i; j++) {temp++;}}System.out.println(temp);}}下列选项中,哪一个是正确的运行结果:

A. 5
B. 9
C. 10
D. 15

请阅读下面的程序public class Test {public static void main(String[] args) {int m = 37;int n = 13;while (m != n) {while (m > n) {m -= n;}while (m < n) {n -= m;}}System.out.println("m=" + m);}}下列选项中,哪一个是正确的运行结果:

A. m=37
B. m=13
C. m=1
D. m=2

请阅读下面的程序。public class Test {public static void main(String[] args) {int a = 0;int b = 0;for (int i = 1; i <= 5; i++) {a = i% 2;while (a-- >= 0) {b++;}}System.out.println("a=" + a + ",b=" + b);}}下列选项中,哪一个是正确的运行结果:

A. a=8,b=-2
B. a=-2,b=8
C. a=0,b=3
D. a=3,b=0

答案查题题库