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

题目内容 (请给出正确答案)

请写出下列代码段的运行结果 int x=0; int y=-1; if(x!=0) if(x>0)y=1; else y=0;


参考答案

更多 “ 请写出下列代码段的运行结果 int x=0; int y=-1; if(x!=0) if(x0)y=1; else y=0;” 相关考题
考题 ( 21 )有如下函数定义:void func ( int a,int & b ) {a++; b++;}若执行代码段:int x=0 ,y=1func ( x,y ) ;则变量 x 和 y 值分别是A ) 0 和 1B ) 1 和 1C ) 0 和 2D ) 1 和 2

考题 下面程序的运行结果是includevoid fun(int * a,int * b){ int x= * a; * a = * b;* 下面程序的运行结果是 #include<iostream.h> void fun(int * a,int * b) { int x= * a; * a = * b; * b=x; cout <<*a<< *b<<""; } void main( 0 { int x =1,y =2; fun(x,y); cout<< x << y <<end1; }A.12 12B.12 21C.21 12D.21 21

考题 以下程序段的运行结果是( )。 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"); } }

考题 有如下函数定义;void func(int a,int b){a++;b++;}若执行代码段:int x=0,y=1;func(x,y);则变量x和y的值分别是A.0和1B.1和1C.0和2D.1和2

考题 若有以下程序段: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 class Sample {int x,y;public:Sample() {x=y=0 下列程序的运行结果是【 】。include <iostream. h>class Sample {int x,y;public:Sample() {x=y=0; }Sample(int a, int b) {x=a;y=b;}void disp() {cout<<" x=" <<x<<" , y="<<y<<end1;}};void main() {Sample s1, s2(1, 2);s1. disp0;s2. disp ();}

考题 下面程序的运行结果为_____。 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) ;}

考题 下列程序的运行结果是 includeclass Location{private:int X.Y;public:void init(i 下列程序的运行结果是 #include<iostream.h> class Location{ private: int X.Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX( ){ return X;} void valueYA.5 0 6 4B.0 0 6 4C.5 0 6 2D.0 0 6 2

考题 执行下列程序段,结果是includevoid main( ){int x=40; char y='C'; int n;?n=(x char y='C'; int n; ? n=(x0) xff) (y>'B') ; cout < < n;}A.0B.1C.2D.3

考题 下列程序段执行后的输出结果为 int x=3; int y=10; System.out. println(y %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

考题 下列程序段的运行结果是______。int x=0,y=0;while(x<15) y++,x+=++y;pfintf("%d,%d",y,x);

考题 下列程序的运行结果是()。includevoid sub(int*s,int*y){static int m=4;*y=s[0];m++;} 下列程序的运行结果是( )。 #include<stdio.h> void sub(int*s,int*y) {static int m=4; *y=s[0]; m++; } void main() {int a[]={1,2,3,4,5},k; int x; printf("\n"); for(k=0;k<=4;k++) {sub(a,x); printf("%d,",x); } }A.1,1,1,1,1,B.1,2,3,4,5,C.0,0,0,0,0,D.4,4,4,4,4,

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

考题 下列程序段的输出结果是includevoid fun(int * x,int * y){cout 下列程序段的输出结果是 #include<iostream.h> void fun(int * x,int * y) { cout << * X << * y; *X=3; *y=4; } void main() { int x=1,y=2; fun(y,x); cout << X << y<<endl; {A.2143B.1212C.1234D.2112

考题 下列程序的运行结果是()。includevoid sub(int*s,int*y){static int m=4:*y=s[m];m--;} 下列程序的运行结果是( )。 #include<stdio.h> void sub(int*s,int*y) {static int m=4: *y=s[m]; m--; } void main() {int a[]={1,2,3,4,5},k,x; printf("\n"); for(k=0;k<=4;k++) {sub(a,x); printf("%d,",x); } }A.5,4,3,2,1,B.1,2,3,4,5,C.0,0,0,0,0,D.4,4,4,4,4,

考题 下列程序运行时的输出结果是______。 include using namespace std; void Xfun(intvoid Xfun(int, int);int main(){int a=3, b=4;Xfun(a, B) ;cout<<a*a+b<<end1;return 0;}void Xfun(int x, int y){int z=x;x=y; y=z;}

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

考题 运行以下的程序代码,结果是()。includeusing namespace std;intmain(){int x=5;int *q 运行以下的程序代码,结果是( )。 #include<iostream> using namespace std; intmain() { int x=5; int *q=x; int y=x; y++; tout<<(*q)++<<end1; return 0; }A.5B.6C.7D.8

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

考题 在下面程序运行后,输出结果为 ______。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

考题 阅读以下代码,回答问题:1至问题3 ,将解答填入答题纸的对应栏内。 【代码1】 includestdio.h void swap(int x, int y) { int tmp =x; x= y; y= tmp; } int maim() { int a= 3, b= 7; printf(a1= %d b1=%d\n,a,b); Swap( a, b); Printf(a2 = %d b2=%d\n,a,b); return 0; } 【代码2】 includestdio.h define SPACE //空格字符 Int main() { char str[128] = Nothing is impossible! ; int i,num =0,wordMark=0; for(i=0;str[i];i++) If(str[i]==SPACE) WordMark=0; else If(wordMark=0){ wordMark=1; num++; } Printf(%d/n,num) return 0; } 【代码3】 includestdio.h define SPACE //空格字符 int countStrs(char *); int main() { char str[128] = Nothing is impossible! ; Printf(%d/n,(1)(str)) return 0; } int countStrs(char *p) { int num=0, wordMark= 0; for(;(2); p++) { If((3)==SPACE) wordMark= 0; else if( !wordMark ) { wordMark = 1; ++num } } return (4) ; }【问题1】(4分) 写出代码1运行后的输出结果。 【问题2】(3分) 写出代码2运行后的输出结果。 【问题3】(8分) 代码3的功能与代码2完全相同,请补充3中的空缺,将解答写入答题纸的对应栏内。

考题 下列程序段的输出结果是 include void fun(int * X,int * y) {cout 下列程序段的输出结果是 #include<iostream.h> void fun(int * X,int * y) { cout < < * X < < * y; * X=3; * y=4; } void main( ) { int x=1,y=2; fun(y,x); cout < < X < < y < < end1; }A.2143B.1212C.1234D.2112

考题 阅读以下代码,回答问题:1 至问题 3 ,将解答填入答题纸的对应栏内。【代码 1】#include void swap(int x, int y){int tmp =x; x= y; y= tmp;}int maim(){int a= 3, b= 7;printf("al= %d b1=%d\n",a,b); Swap( a, b);Printf("a2 = %d b2=%d\n”,a,b); return 0;} 【代码 2】#include#define SPACE ¨ //空格字符 Int main(){char str[128] =”Nothing is impossible! “; int i,num =0,wordMark=0; for(i=0;str[i];i++) If(str[i]=SPACE)WordMark=0;elseIf(wordMark=0){ wordMark=1;Mun++;} Printf(“%d/n”,num) retun 0; } 【代码 3】#include#define SPACE “//空格字符 int countStrs(char *); int main(){char str[128] = " Nothing is impossible! "; Printf(‘%d/n,(1)(str))retum 0; } int countStrs(char *p){int num=0, wordMark= 0; for(;(2);p++) {If((3)=SPACE)wordMark= 0;elseif( !wordMark ) { wordMark = 1;++mun}}retum (4) ;}【问题 1】(4 分)写出代码 1 运行后的输出结果。【问题 2】(3 分)写出代码 2 运行后的输出结果。【问题 3】(8 分)代码 3 的功能与代码 2 完全相同,请补充 3 中的空缺,将解答写入答题纸的对应栏内。

考题 请写出下列代码段的运行结果 int i=1,n=-1; if(i==0); n=100; Console.Write(n);

考题 问答题请写出下列代码段的运行结果 int x=0; int y=-1; if(x!=0) if(x0)y=1; else y=0;

考题 问答题请写出下列代码段的运行结果 int i=1,n=-1; if(i==0); n=100; Console.Write(n);