网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
有以下程序#include main(){ int x=1,y=0,a=0,b=0; switch(x) {  case 1:      switch(y)      {       case 0:a++;break;       case 1:b++;break;      }  case 2:a++;b++;break;  case 3:a++;b++; } printf(a=%d,b=%d,a,b);}程序的运行结果是(  )。
A

a=2,b=1

B

a=2,b=2

C

a=1,b=1

D

a=1,b=0


参考答案

参考解析
解析:
当执行swicth语句时,首先计算紧跟其后一对括号中的表达式的值,然后在switch语句体内寻找与该值吻合的case标号。如果有与该值相等的标号,则执行该标号后开始的各语句,包括在其后的所有case和default中的语句,直到switch语句体结束;每当执行到break语句时,立即跳出 switch语句体。switch语句通常总是和break语句联合使用,使得switch语句真正起到分支的作用。本题中,x=1,首先进入外层分支1,接下来y=0,再进入内层分支0,执行a++,此时a=1,接下来遇到break,跳出内层switch;由于外层分支中没有break语句,会继续执行外层分支2,执行a++,b++,此时a=2,b=1;然后遇到break语句,跳出外层switch。答案选择A选项。
更多 “单选题有以下程序#include main(){ int x=1,y=0,a=0,b=0; switch(x) {  case 1:      switch(y)      {       case 0:a++;break;       case 1:b++;break;      }  case 2:a++;b++;break;  case 3:a++;b++; } printf(a=%d,b=%d,a,b);}程序的运行结果是(  )。A a=2,b=1B a=2,b=2C a=1,b=1D a=1,b=0” 相关考题
考题 有以下程序:includeint f(int x){int y;if(x==0||x==1)return(3);y=x*x-f(x-2);return 有以下程序: #include<stdio.h> int f(int x) {int y; if(x==0||x==1)return(3); y=x*x-f(x-2); return y; } main() {int z; z=f(3);printf("%d\n",z); } 程序的运行结果是( )。A.0B.9C.6D.8

考题 请阅读以下程序:includemain(){int x=1,y=0,a=0,b=0;switch(x){case 1:switch(y){case 请阅读以下程序: #include<stdio.h> main() { int x=1,y=0,a=0,b=0; switch(x) { case 1: switch(y) { case 0:a++;break;} case 2: a++,b++;break;} printf("a=%d,b=%d\n",a,b); 上面程序的输出结果是A.a=2,b=1B.a=1,b=1C.a=1,b=0D.a=2,b=2

考题 有以下程序:includemain(){intx=1,y=0,a=0,b=0;switch(x){case 1:switch(y){case 0:a+ 有以下程序: #include<stdio.h> main() { int x=1,y=0,a=0,b=0; switch(x) { case 1: switch(y) { case 0:a++;break; case 1: b++;break; } case 2:a++;b++;break; case 3:a++;b++; } printf("a=%d,b=%d\n",a,B); } 程序的运行结果是( )。A.a=1,b=0B.a=2,b=2C.a=1,b=1D.a=2,b=1

考题 有下列程序:#include"stdio.h"main(){ int x=0;int y=0;while(x<7++y){ y--;x++;}printf("%d,%d",y,x);}程序的输出结果是( )。A.0,7B.7,7C.0,6D.1,6

考题 以下程序段的运行结果是( )。 include main() {int x=2,y=1: switch(x) {case 1: switch 以下程序段的运行结果是( )。 include<stdio.h> main() {int x=2,y=1: switch(x) {case 1: switch(y) {case 0:printf("x=2,y=1\n");break; case 1:printf("y=1\n");break; } case 2:printf("x=2\n"); } }

考题 若有以下程序段:include using namespace std;int main (){ int a[]={1,4,5}; int *p 若有以下程序段: #include <iostream> using namespace std; int main () { int a[]={1,4,5}; int *p=a[0],x=6, y,z; for (y=0; y<3; y++) z= ( (* (p+y) <x) ? *(p+y) :x); cout<<z<<end1; return 0; } 程序运行后的输出结果是( )。A.1B.4C.5D.2

考题 以下程序的执行结果是______。 include void main() { int x=5 y=2; cout 以下程序的执行结果是______。include<iostream.h>void main(){int x=5 y=2;cout<<! (y==x/2)<<",";cout<<(y!=x%3)<<",";cout<<(x>0 y<0=<<",";cout<<(x!=y||x>=y)<<endl;}

考题 有如下程序:includemain(){int x=1,a=0,b=0; switch(x) {casc 0:b++;case 1:a++;case 有如下程序: #include<stdio.h> main() { int x=1,a=0,b=0; switch(x) { casc 0:b++; case 1:a++; case 2:a++;b++; } printf("a=%d,b=%d\n",a,b); } 该程序的输出结果是( )。A.a=2,b=1B.a=1,b=1C.a=1,b=0D.a=2,b=2

考题 有以下程序:include main() {int a[] = {2,4,6,8,10} ,y =0,x, * p;p =a[1];for( 有以下程序: #include <stdio.h> main() { int a[] = {2,4,6,8,10} ,y =0,x, * p; p =a[1]; for(x=1;x<3;x++)y+ =p[x]; printf( "% d \n" , y); }程序运行后的输出结果是( )。A.10B.11C.14D.15

考题 下面程序的运行结果为_____。 include void fun(int x=0,int y=0) { cout 下面程序的运行结果为_____。include<iostream.h>void fun(int x=0,int y=0){cout < < x < < y;}void main( ){fun(5) ;}

考题 有如下程序:include void fun(int x, int y){int t=x;x=y;y=t;}int main (){int 有如下程序: #include <iostream> void fun(int x, int y){int t=x;x=y;y=t;} int main () { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; } 执行后的输出结果是A.42,42B.23,23C.23,42D.42,23

考题 有以下程序:include main(){inty=9;for( ; y>0; y--)if(y%3==0) printf("%d", --y);} 有以下程序: #include <stdio.h> main() {int y=9; for( ; y>0; y--) if(y%3==0) printf("%d", --y); } 程序的运行结果是( )。A.741B.963C.852D.875421

考题 有以下程序 include main() { int y=9; for( ; y>0; y--) if(y% 有以下程序 #include <stdio.h> main() { int y=9; for( ; y>0; y--) if(y%3==0) printf("%d",--y); } 程序的运行结果是A.741B.963C.852D.875421

考题 有以下程序 include main() { int a=1, b=2, c=3, x; x=(a^b)c; pri 有以下程序 #include <stdio.h> main() { int a=1, b=2, c=3, x; x=(a^b)c; printf("%d\n",x); } 程序的运行结果是A.0B.1C.2D.3

考题 请选出以下程序的输出结果includemain(){ int a[]={1,2,3,4},i;int x=0;for(i=0;i 请选出以下程序的输出结果 #include<stdio.h> main() { int a[]={1,2,3,4},i; int x=0; for(i=0;i<4;i++) { sub(a,x);printf("%d",x);} printf("\n");} sub(s,y) int*s,y; { static int t=3; y=s[t];t--; }A.1 2 3 4B.4 3 2 1C.0D.4444

考题 有以下程序:includevoid main(){int x=l0,y=l0:for(int i=0;x>8;y=++i)cout 有以下程序: #include<iostream.h> void main() { int x=l0,y=l0: for(int i=0;x>8;y=++i) cout<<x--<<","<<y<<",": } 该程序运行后的输出结果是( )。A.10,1,9,2B.9,8,7,6C.10,9,9,0D.10,10,9,1

考题 有以下程序includemain(){intx=1,y=0,a=0,b=0;switch(X){case1:switch(y){case0:a++;b 有以下程序 #include <stdio.h> main() { int x=1,y=0,a=0,b=0; switch(X) { case 1: switch(y) { case 0:a++; break; case 1:b++; break; } case 2:a++;b++;break; case 3:a++;b++; } printf("a=%d,b=%d\n",a,b); } 程序A.a=1,b=0B.a=2,b=2C.a=1,b=1D.a=2,b=1

考题 有以下程序includeintf(intx){inty;if(x==0||x==1)return(3);y=x*x-f(x-2);returny;}m 有以下程序 #include <stdio.h> intf(int x) { int y; if(x==0||x==1) return(3); y=x*x-f(x-2); return y; } main() { int z; z=f(3); printf("%d\n",z); } 程序的运行结果是A.0B.9C.6D.8

考题 以下程序运行后的输出结果是( )。 include main() { int x=20; printf("%d", 0 以下程序运行后的输出结果是( )。include<stdio.h>main(){ int x=20;printf("%d", 0<x<20);printf("%d\n", 0<x x<20);}

考题 有下列程序:includemain(){int x=1,y=0,a=0,b=0;switch(x){ case 1:switch(y){ case 0 有下列程序: #include <stdio.h> main() { int x=1,y=0,a=0,b=0; switch(x) { case 1: switch(y) { case 0:a++;break; case 1:b++;break; } case 2: a++;b++;break; case 3: a++;b++; } printf("a=%d,b=%d\n",a,B) ; } 程序的运行结果是( )。A.a=1,b=0B.a=2,b=2C.a=1,b=1D.a=2,b=1

考题 有下列程序: include int f(int x) { int y; if(x=0‖x==1)r 有下列程序: #include <stdio.h> int f(int x) { int y; if(x=0‖x==1)return(3); y=x*x-f(x-2); return y; } main() { int z; z=f(3);printf("%d\n",z); 程序的运行结果是( )。A.0B.9C.6D.8

考题 关于下面的程序 include main() { int x=3,y=0,z=0; if(x=y+z)printf("****"); else p 关于下面的程序 #include<stdio.h> main() { int x=3,y=0,z=0; if(x=y+z)printf("****"); else printf("$$$$"); }说法正确的是______。A.有语法错误不能通过编译B.输出****C.输出$$$$D.可以通过编译,但不能通过连接,无法运行

考题 有以下程序:includevoid main(){ int x=5,y=2; cout 有以下程序: #include<iostream.h> void main() { int x=5,y=2; cout<<!(y==x/2)<<","; cout<<y!=x%3)<<","; cout<<(x>0y<0)<<","; cout<<(x!=y‖x>=y)<<endl: } 程序执行后的输出结果是( )A.0,0,0,1B.1,1,1 1C.0,0, 1,1D.1,1,0,0

考题 有以下程序: include using namespace std; int main() {int x;for(int i=1;i 有以下程序: #include <iostream> using namespace std; int main() { int x; for(int i=1;i<=100;i++) { x=i; if (++x%2==0) if (++x%3==0) if (++x%7==0) cout<A.39,81B.42,84C.26,68D.28,70

考题 有下列程序: #include " stdio.h" main() { int x=0; int y=0; while (x<7++y) { y--; x++;} printf("%d,%d",y,x); } 程序的输出结果是( )。A.0, 7B.7, 7C.0,6D.1,6

考题 有以下程序:includemain(){int x=3,y=2,z=1; printf("%d\n",x/y~z);程序运行后的 有以下程序: #include <stdio.h> main() { int x=3,y=2,z=1; printf("%d\n",x/y~z); 程序运行后的输出结果是( )。A.3B.2C.1D.0

考题 有以下程序includeint f(intx){inty; if(x==0||x==1)return(3); y=x*x-f(x-2); return 有以下程序 #include <stdio.h> int f(int x) { int y; if(x==0||x==1) return(3); y=x*x-f(x-2); return y; } main() { int z; z=f(3); printf("%d\n",z); } 程序的运行结果是A.0B.9C.6D.8

考题 单选题有以下程序:#include main(){ int x=1,y=0; if(!x)y++; else if(x==0) if(x)y+=2;  else y+=3; printf(%d,y);}程序运行后的输出结果是(  )。A 3B 2C 1D 0