网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
有以下程序:#includestruct S{int a;int *b;};main(){ int x1[] = {3,4},x2[] = {6,7}; struct S x[] = {1,x1,2,x2}; printf(%d,%d,*x[0].b,*x[1].b);}程序的运行结果是( )。
A
1,2
B
3,6
C
4,7
D
变量的地址值
参考答案
参考解析
解析:
程序的执行过程为:定义整型数组x1,x2并进行初始化,两个数组长度均为2。定义结构体数组x,并为其初始化,则x[0].a=1,x[0].b=x1,x[1].a=2,x[1].b=x2。输出x[0]的成员指针b指向的内存单元值,即数组x1的第一个元素3,输出x[1]的成员指针b指向的内存单元值,即数组x2的第一个元6。程序的运行结果是3,6。答案选择B选项。
程序的执行过程为:定义整型数组x1,x2并进行初始化,两个数组长度均为2。定义结构体数组x,并为其初始化,则x[0].a=1,x[0].b=x1,x[1].a=2,x[1].b=x2。输出x[0]的成员指针b指向的内存单元值,即数组x1的第一个元素3,输出x[1]的成员指针b指向的内存单元值,即数组x2的第一个元6。程序的运行结果是3,6。答案选择B选项。
更多 “单选题有以下程序:#includestruct S{int a;int *b;};main(){ int x1[] = {3,4},x2[] = {6,7}; struct S x[] = {1,x1,2,x2}; printf(%d,%d,*x[0].b,*x[1].b);}程序的运行结果是( )。A 1,2B 3,6C 4,7D 变量的地址值” 相关考题
考题
有以下程序#include stdio.hstruct ord{ int x,y; } dt[2]={1,2,3,4};main(){ struct ord *p=dt;printf("%d,",++p-x); printf("%d\n",++p-y);}程序的运行结果是A)1,2B)2,3C)3,4D)4,1
考题
以下程序输出结果为______。 include using namespace std; class TestClass 1 { publi
以下程序输出结果为______。include<iostream>using namespace std;class TestClass 1{public:TestClass1(){}TestClass1(int i){x1=i;}void dispa(){cout<<"x1="<<x1<<",";}private:int x1;}:class TestClass2:public TestClass1{public:TestClass2(){}TestClass2(int i):TestClass1(i+10){x2=i:}void dispb(){dispa();cout<<"x2="<<x2<<end1;}private:int x2:}:int main(){TestClass2 b(2):b.dispb();return 0;}
考题
(37)有以下程序#include stdio.hstruct ord{ int x,y;} dt[2]={1,2,3,4};main(){ struct ord *p=dt;printf (“%d,”,++p-x); printf(“%d\n”,++p-y);}程序的运行结果是A)1,2 B)2,3 C)3,4 D)4,1
考题
有以下程序: #includestdio.h int fun {static int x=1; x+=1;return X; } main {int i,S=1; for(i=1;i=S;i++)s+=fun; printf("%d\n",s); } 程序运行后的输出结果是( )。A.11B.21C.6D.120
考题
下程序( )。 main( ) { int x1=3, x2=0, x3=0; if (x1=x2+x3) printf("* * * *"); else printf(" "); }
A.输出:* * * *B.输出:# # #C.#存在语法错误D.无输出结果
考题
有以下程序 include typedef struct { int num;double s; }REC; void funl(REC *x) { x
有以下程序 include<stdio.h> typedef struct { int num;double s; }REC; void funl(REC *x) { x->num=23;x->s=88.5; } void main() { REC a={16,90.0}; fun1(A); printf("%d\n",a.num); } 程序运行后的输出结果是( )。
考题
以下程序的输出结果是( )。 main {int x=0.5;char z=a; printf("%d\n",(x2));}A.0S
以下程序的输出结果是( )。 main {int x=0.5;char z=a; printf("%d\n",(x&1)&&(z2));}A.0B.1C.2D.3
考题
以下程序的输出结果是【 】。include int fun(int x) {static int t=0; return(t+=x); }
以下程序的输出结果是【 】。include <stdio.h>int fun(int x){ static int t=0;return(t+=x);}main()int s,i;for(i=1 ;i<=5;i++) s=fun(i);printf("%d\n",s);
考题
执行下列程序 int fun(int x1,int x2){ int x; x1>x2 ?(x=3):(x=4); return x+x1; } void main(){ cout<<fun(7,8); } 后输出结果是 ______。A.9B.10C.11D.12
考题
有以下程序includestruct ord{ int x,y;} dt[2]={1,2,3,4};mare(){struct ord*p=dt; p
有以下程序 #include<stdio.h> struct ord { int x,y;} dt[2]={1,2,3,4}; mare() { struct ord*p=dt; printf("%d,",++p->x); printf("%d\n",++p->y); } 程序的运行结果是______。A.1,2B.2,3C.3,4D.4,1
考题
有如下程序: include class x { protected: int a; public:x(){ a=1;} }; class x
有如下程序: #include <iostream.h> class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<a; } }; class x2 : virtual public x { public: x2() { a+=2; cout<<a; } }; class y : public xl,public x2 { public: y() { cout<<a<<end1; } }; int main() { y obj; return O; } 该程序运行后的输出结果是( )。A.1B.123C.242D.244
考题
有以下程序#includestdio.hstruct ord{int x,y;} dt[2]={1,2,3,4};main(){struct ord*p=dt;printf(“%d,”,++(p一x));printf(“%d\n”,++(p一y));}程序运行后的输出结果是A.1,2B.4,1C.3,4D.2.3
考题
有以下程序#inculde stdio.hint Fun(){ ststic int x=1;x*=2;return x;}main (){ int i,s=1;For(i=1;I=2,I + +) s =Fun();printF(“%d\n”,s);}程序运行后的输出结果是A.0B.1C.4D.8
考题
有以下程序: #includestdio.h struct ord {int X,y;)dt[2]={1,2,3,4}; main( ) { struct ord*p=dt; printf("%d,",++(p-x));printf("%d\n",++(p-y)); } 程序运行后的输出结果是( )。A.1,2B.4,1C.3,4D.2,3
考题
有以下程序: #includestdio.h int fun( ) {static int x=1; X*=2;return X; main( ) int i,s=1; for(i=1;i=2;i++)s=fun( ); printf{¨%d\n",s); } 程序运行后的输出结果是( )。A.0B.1C.4D.8
考题
若有以下程序:include using namespaces std;class A{public: A (){} A (int i) {x1=
若有以下程序: #include <iostream> using namespaces std; class A { public: A (){} A (int i) { x1=i; } void dispa() { cout<<"xl="<<xl<<" , "; } private: int x1; }; class B : public A { public: B (){} B (int i):A(i+10) { x2=i; } void dispb() { dispa (); cout <<"x2="<<x2<<end1; } private: int x2; }; int main () { B b(2); b.dispb (): return 0; } 程序运行后的输出结果是( )。A.x1=10,x2=2B.x1=12,x2=10C.x1=12,x2=2D.x1=2,x2=2
考题
有以下程序: #includestdio.h int fun( ) {static int x=1; X*=2: return x; } main( ) {int i,S=1; for(i=1;i=3;i++)S*=fun( ); printf("%d\n",s); } 程序运行后的输出结果是( )。A.0B.10C.30D.64
考题
若有以下程序:includeusing namespaces std;class A{public: A(){} A(int i) {xl=i;
若有以下程序: #include<iostream> using namespaces std; class A { public: A(){} A(int i) { xl=i; } void dispa() { cout<<"x1="<<x1<<","; } private: int x1; }; class B:public A { public: B(){} B(int i):A(i+10) { x2=i; } void dispb() { dispa(); cout<<"x2="<<x2<<endl; } private: int x2; }; int main{) { B b(2); b.dispb(): return 0; } 程序运行后的输出结果是A.x1=10,x2=2B.x1=12,x2=10C.x1=12,x2=2D.x1=2,x2=2
考题
以下程序的输出结果是includestruct st{ int x;int *y;}*p;int dt[4]={10,20,30,40};s
以下程序的输出结果是 #include<stdio.h> struct st { int x;int *y;}*p; int dt[4]={10,20,30,40}; struct st aa[4]={50,dt[0],60,dt[0],60,dt[0],60,dt[0],}; main() { p=aa; printf("%d\n",++(p->x));}A.10B.11C.51D.60
考题
若有以下程序:includeusing namespaces std;class A{public:A(){}A(int i){x1=i; } v
若有以下程序: #include<iOStream> using namespaces std; class A { public: A(){} A(int i) { x1=i; } void dispa() { cout<<"X1="<<x1<<",": } private; int x1; }; class B:public A { public: B(){} B(int i):A(i+10) { x2=i; } void dispb() { dispa(); cout<<"x2="<<x2<<end1; } private: int x2; }; . int main() { B b(2); b.dispb() return 0; } 程序运行后的输出结果是( )。A.x1=10,x2=2B.x1=12,x2=10C.x1=12,x2=2D.x1=2,x2=2
考题
若有以下程序:include using namespace std;class A{public:A() { }A(int i){x1=i;}v
若有以下程序: #include <iostream> using namespace std; class A { public: A() { } A(int i) { x1=i; } void dispa0 { cout<<"x1="<<x1<<","; } private: int x1; }; class B: public A { public: B() { } B(int i):A(i+10) { x2=i; } void dispb() { dispa(); cout<<"x2="<<x2<<endl; } private: int x2; }; int main() { B b(2); b.dispb(); return 0; } 程序运行后的输出结果是( )。A.x1=10,x2=2B.x1=12,x2=10C.x1=12,x2=2D.x1=2,x2=2
考题
执行下列程序后的输出结果是( ) int fun(int x1,int x2) { int x;x1x2?(x=3):(x=4);return(x+x1); } main() { printf("%d\n",fun( 7,8));}A.9B.10C.11D.12
考题
(37)有以下程序#include stdio.hstruct ord{ int x,y;}dt[2]={1,2,3,4};main(){struct ord *p=dt;printf("%d,",++(p-x)); printf("%d\n",++(p-y));}程序运行后的输出结果是A)1,2B)4,1C)3,4D)2,3
考题
单选题有以下程序:#include int fun(){ static int x=1; x*=2; return x;}main(){ int i,s=1; for(i=1;i=2;i++)s=fun(); printf(%d,s);}程序运行后的输出结果是( )。A
0B
1C
4D
8
考题
单选题有以下程序:#include int fun(){ static int x=1; x+=1; return x;}main(){ int i,s=1; for(i=1;i=5;i++)s+=fun(); printf(%d,s);}程序运行后的结果是( )。A
11B
21C
6D
120
考题
单选题有以下程序:#include main(){ char c='A'; int x=36,b; b=(x2)(c'a'); printf(%d,b);}程序运行后的输出结果是( )。A
1B
0C
2D
4
考题
单选题有以下程序:#include int fun(){ static int x=1; x*=2; return x;}main(){ int i,s=1; for(i=1;i=3;i++)s*=fun(); printf(%d,s);}程序运行后的输出结果是( )。A
0B
10C
30D
64
热门标签
最新试卷