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

题目内容 (请给出正确答案)
单选题
有以下程序:#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

3

B

2

C

1

D

0


参考答案

参考解析
解析:
else子句总是与前面最近的不带else的if相结合,与书写格式无关。本题中的层次关系是:if(!x)与else if(x==0)是一组,位于条件判断的最外层。而if(x)与else是一组,位于else if(x==0)条件的内层。由此可知条件均不成立,所以y未进行任何操作,仍为0。答案选择D选项。
更多 “单选题有以下程序:#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” 相关考题
考题 有以下程序: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

考题 有以下程序#include stdio.hint 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

考题 有以下程序: #includestdio.h main( ) {int x=1,y=0; if(!x)y++; else if(x==0) if(x)y+=2; else y+=3; Drintf("%d\n"。v); } 程序运行后的输出结果是( )。A.3B.2C.1D.0

考题 若有以下程序段: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 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:: ond1; retum0; }执行后的输出结果是______ 。A.41,41B.23,23C.13,42D.42,23

考题 有以下程序:includeusing namespace std;int f(int,int);int main(){ int i:1,x; x=f 有以下程序: #include<iostream> using namespace std; int f(int,int); int main() { int i:1,x; x=f(i,i+1); cout<<x<<end1; return 0; } int f(int a,int b) { int c; c = a; if(a>b) c = 1; else if(a==b) c = 0; else c = -2; return c; } 运行后的输出结果是( )。A.1B.0C.-1D.-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;}

考题 下面程序的结果【】。 include int f(int); void main() { int x=1,i; for (i=0; i 下面程序的结果【 】。include<iostream.h>int f(int);void main() {int x=1, i;for (i=0; i<3; i++)cout<<f(x)<<‘ ’ ;cout<<end1;}int f(int x){int y=1;static int z=3y++;z++;return (x+y+z);}

考题 有以下程序: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

考题 有以下程序: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

考题 有以下程序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

考题 有以下程序 main() { int x=0,y=0,i; for(i=1;++i) { if(i%2==0) {x++;continue;} if(i%5==0){y++;break;}} printf("%d,%d",x,y);} 程序的输出结果是A.2,1B.2,2C.2,5D.5,2

考题 有下列程序: 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

考题 有以下程序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

考题 若有以下程序段;includeusing 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

考题 有以下程序#inclUdestdio.hmain(){int x=1。y=0;if(!x)y++;else if(x==0)if(x)y+=2;else y+=3; .printf(“%d\n”,y);}程序运行后的输出结果是A.3B.2C.1D.0

考题 有以下程序:includevoid main(){int x=10,y=10;for(int i=0;x>8;y=++i)cout 有以下程序: #include<iostream.h> void main() { int x=10,y=10; 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(){ int x=1,y=0;if(!x) y++;else if(x==0)if (x) y+=2;else y+=3;printf(%d\n,y);}程序运行后的输出结果是A.3B.2C.1D.0

考题 下面程序输出的结果是()。includeusing namespace std;int fuc (char *x);int main(){ 下面程序输出的结果是( )。 #include<iostream> using namespace std; int fuc (char *x); int main(){ cout<<fuc("hello")<<endl; return 0; } int fuc(char *x){ char *y=x; while(*y! ='\0')y++; return(y-x); }A.5B.6C.0D.语法错误,不能输出结果

考题 在下面程序运行后,输出结果为 ______。includevoid count(int x[],int n,int y 在下面程序运行后,输出结果为 ______。 #include<iostream.h> void count(int x[],int n,int y){ int k; y=0; for(k=0:k<n;k++) if(x[k]<0) y++; } void main(){ int b[]={2,1,-8,-3,7,2,4,6,0,-13}; int x; count(b,10,x); cout<<“x”<<x<<end1; }A.x=3B.x=5C.出错D.x=0

考题 (27)有以下程序#include stdio.hmain(){ int x=1,y=0;if(!x) y++;else if(x==0)if (x) y+=2;else y+=3;printf("%d\n",y);}程序运行后的输出结果是A)3B)2C)1D)0

考题 单选题有以下程序:#include 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,z);}程序的运行结果是(  )。A 0B 9C 6D 8