举一反三
- 写出下面程序运行结果。 public class Demo { public static void main(String args[]) { int x = 9, y = 11, z = 8; int t, w; t = x > y ? x : y + x; w = t > z ? t : z; System.out.println(w); } }
- 以下程序执行后的输出结果是 #include <iostream> using namespace std; void try(int,int,int,int); int main () int x,y,z,r; x =1 ; y = 2; try(x,y,z,r); cout<<r<<endl; return 0; void try(int x,int y,int z,int r) z = x+y; x = x*x; y = y*y; r = z+x+y; A: 18 B: 9 C: 10 D: 不确定
- 请阅读下面的程序 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 B{ public static void main(String[] args) { int x = 5; double y = 10.5f; float z = (float)(x*y); System.out.println(z); } }
- #include[stdio.h] main(){ int x=10,y=5; switch(x) { case 1:x++; default:x+=y;case 2:y--;case 3:x--;}printf("x=%d,y=%d\n",x,y);}程序的运行结果为 。
内容
- 0
(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(); } }
- 1
阅读程序,分析输出结果是()。#include [stdio.h]void main(){ int x=10,y=5; switch(x) { case 1:x++; default: x+=y;case 2:y--;case 3:x--;}printf("x=%d,y=%d",x,y);} A: x=14,y=4 B: x=15,y=5 C: x=10,y=5 D: x=15,y=4
- 2
阅读程序,分析输出结果是()。#include [stdio.h]void main(){ int x=10,y=5; switch(x) { case 1:x++; default: x+=y;case 2:y--;case 3:x--;}printf("x=%d,y=%d",x,y);} A: x=15,y=5 B: x=10,y=5 C: x=14,y=4 D: x=15,y=4
- 3
从($y)("x)R(x,y)不能推出的是: A: ("x)($y)R(x,y) B: ("y)($x)R(x,y) C: ($x)($y)R(x,y) D: ($y)($x)R(x,y)
- 4
有以下程序段,运行后的输出结果是( ) #include main() {int x=10,y=5; switch(x) { case 1: x++; default:x+=y; case 2:y--; case 3:x--; } printf(“x=%d,y=%d”,x,y); } A: x=15,y=5 B: x=10,y=5 C: x=14,y=4 D: x=15,y=4