更多"[单选题]分析下列代码片段的执行结果()
int a=1; int "的相关试题:
[单选题]分析下列代码片段的执行结果()
int count = 5;
while (count > 1)
{
--count;
Console.Write(count);
}
A.4332
B.4321
C.4521
D.4322
[单选题]在执行时从键盘上输入9,分析下列代码片段的执行结果是()
int n= int.Parse(Console.ReadLine());
if (n++ < 10){
Console.WriteLine("{0}", n);
}else{
Console.WriteLine("{0}",n--);}
A.11
B.10
C.9
D.8
[单选题]分析下列代码片段的执行结果()
int num1 = 22; int num2 = 7;
if (num1 > num2) {
Console.WriteLine("num1大");
Console.WriteLine("num1={0}", num1);
} else {
Console.WriteLine("num2大");
Console.WriteLine("num2={0}", num2);
}
A.num1大;num1=22
B. num2大;num2=7
C.num1大num1=22
num2大num2=7
D. 语法错误不能运行
[单选题]分析下列代码片段的执行结果()
int x = 8;
int y = x++;
Console.WriteLine(y);
y = ++x;
Console.WriteLine(y);
A.8 9
B.9 9
C.9 10
D. 8 10
[单选题]分析下列代码片段的执行结果()
int score = 80;
if (score > 90) {
Console.WriteLine("好");
} else if (score > 80) {
Console.WriteLine("良好");
} else {
Console.WriteLine("一般");
}
A.好
B.良好
C.一般
D.80
[单选题]分别从控制台输入6和3,分析下列代码片段的执行结果是()
int x= int.Parse(Console.ReadLine());
if (x++>5){
Console.WriteLine(x);
}else {
Console.WriteLine(x--);
}
A.7和5
B.6和3
C.7和4
D.6和4
[单选题]分析下列代码片段的执行结果()
int a = 10, b = 10;
string c=”10”;
Console.WriteLine(a+b+c);
A.2010
B.30
C.101010
D.编译报错,提示数据类型不匹配
[单选题]分析下列代码片段的执行结果()
int a = 10; string b = "10";
Console.WriteLine(a+b);
A.20
B.1010
C.10+10
D.语法错误
[单选题]分析下列代码片段的执行结果()
int x=5,y=10;
Console.WriteLine("{0}+{1}={2}",y,x,y+x);
A.y+x=15
B.x+y=15
C.5+10=15
D.10+5=15
[单选题]当month等于9时,分析下列代码片段的执行结果()
int days = 0;
switch (month)
{
case 2:
days = 28;
break;
case 4:
case 6:
case 9:
case 11:
days = 30;
break;
default:
days = 31;
break;
}
Console.WriteLine(days);
A.0
B.30
C.29
D.31
[单选题]分析下列代码片段的执行结果是()
int a = 21, b = 22, c = 23;
if (a < b)
{
Console.WriteLine(b);
} else {
Console.WriteLine(a + b + c);
}
A.21
B.22
C.23
D.66
[单选题]分析下列代码片段的执行结果()
int y = 1, x;
if (y != 0) {
x = 5;
}else if (y < 0) {
x = 4;
}else{
x = 3;
}
Console.WriteLine("x={0}", x);
A.4
B.3
C.5
D.以上都不对
[单选题]分析下列代码片段的执行结果()
int x = 2, y = -1, z = 2;
if (x < y){
if (y < 0) {
z = 0
};
}else{ z += 1;}
Console.WriteLine("{0}",z);
A.3
B.2
C.1
D.0
[单选题]分析下列代码片段的执行结果()
int x, y = 1, z = 0;
if (z < 0) {
x = 3;
} else if (y == 0) {
x = 5;
}else{
x = 7;
}
Console.WriteLine(x + "," + y);
A. 7, 1
B.7, 1
C.3, 3
D.以上都不正确
[单选题]分析下列代码片段的执行结果是()
int a = 15, b = 21, m = 0;
switch (a % 3)
{
case 0: m++; break;
case 1: m++;
switch (b % 2)
{
case 0: m++; break;
default: m++; break;
}break;}Console.WriteLine("{0}",m);
A.1
B.2
C.3
D.4
[单选题]分析下列代码片段的执行结果()
int a=5,b=4,c=6,d;
Console.WriteLine("{0}", d = a > b ? (a > c ? a : c) : b);
A.5
B.4
C.6
D.不确定
[单选题]分析下列代码片段的执行结果()
int x=1,a=0,b=0;
switch(x){
case 0:b++;break;
case 1:a++;break;
case 2:a++;b++;break;
}Console.WriteLine("a={0},b={1}",a,b);
A.a=2,b=1
B.a=1,b=1
C.a=1,b=0
D.a=2,b=2
[单选题]分析下列代码片段的执行结果()
int a=9, b=6, c;
c=a/b+0.8;
Console.WriteLine(c);
A.1.8
B.2
C.2.3
D.编译错误
[单选题]分析下列代码片段的执行结果是()
if (true) {
Console.Write("Hello");
Console.Write("World");
}
A.无输出
B.HelloWorld
C.Hello
D.Hello World