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

题目内容 (请给出正确答案)
单选题
有如下程序: #include  main() {  int a=0,*ptr;   ptr=&a;  *ptr=3;  a=(*ptr)++;  printf(%d,%d,a,*ptr);  } 程序运行后的输出结果是(  )。
A

4,4

B

0,1

C

1,4

D

0,4


参考答案

参考解析
解析:
程序执行过程为:定义整型变量a=0与指针ptr,使指针指向变量a。对指针指向的变量进行赋值a=3,将指针所指向变量加1,并赋值给a=4,此时指针依然指向变量a,输出a与指针指向的变量值:4,4,答案选择A选项。
更多 “单选题有如下程序: #include main() {  inta=0,*ptr;  ptr=a;  *ptr=3;  a=(*ptr)++;  printf(%d,%d,a,*ptr); } 程序运行后的输出结果是(  )。A 4,4B 0,1C 1,4D 0,4” 相关考题
考题 ( 29 )有如下程序:#includeusing namespace std;class point {public:static int number;public:point () {number++;~ point () {number-;}};imt point::number=0;void main () {point*ptr;printA,B;{point*ptr_point=new point{3};ptr=ptr_point;}pointC;coutPOINT::NUMBERENDL;delete[]ptr;}运行时输出的结果是A ) 3B ) 4C ) 6D ) 7

考题 ( 27 )有如下程序:#includeiostreamusing namespace std;class MyClass{public:MyClass(){++count;}~MyClass(){--count;}static int getCount(){return count;}private:static int count;};int MyClass::count=0;int main(){MyClass obj;coutobj.getCount();MyClass*ptr=new MyClass;coutMyClass::getCount();delete ptr;coutMyClass::getCount();return 0;}程序的输出结果是A ) 121B ) 232C ) 221D ) 122

考题 ( 32 )有如下程序;#includeiostreamusing namespace std;class Base{public:void output(){cout1;}virtual void Print(){cout'B';}};class Derived:public Base{public:void output(){cout2;}void Print(){cout'D';}};int main(){Base *ptr=new Derived;ptr-output();ptr-Print();delete ptr;return 0;}程序的输出结果是A ) 1BB ) 1DC ) 2BD ) 2D

考题 ( 35 )有如下程序:#include iostreamusing namespace std;Class B{public:B(int xx):x(xx) {++cout; x+=10;}virtual void show() const{coutcount ' _ ' xendl;}protected:static int count;private:int x;};class D:public B{public:D(int xx,int yy):B(xx),y(yy) {++count; y+=100;}virtual void show() const{coutcount ' _ ' yendl;}private:int y;};int B::count=0;int main(){B *ptr=new D(10,20);ptr-show();delete ptr;return 0;}运行时的输出结果是A ) 1_120B ) 2_120C ) 1_20D ) 2_20

考题 使用VC6打开考生文件夹下的工程test7_1,此工程包含一个源程序文件test7_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:Constructor1Constructor1Constructor1DestructorConstructor2Destructorx=0x=5DestructorDestructor源程序文件test1_1.cpp清单如下:include<iostream.h>class B{int X;public:B(){X=0;cout<<"Constructorl"<<endl;}B(int i){x=i;cout<<"Constructor2"<<endl;}~B(){cout<<"Destructor"<<endl;}/**********found*********/~B(int i){cout<<i<<"be Destructor"<<endl;}void print(){cout<<"x="<<x<<endl;}};void main(){B *ptr;ptr=new B[2];/**********found*********/ptr[0]=B(0);ptr[1]=B(5);/**********found********/for(int i=0; i<2;)ptr[i].print();delete []ptr;}

考题 有如下程序: include using namespace std; class MyClass { public: 有如下程序: #include <iostream> using namespace std; class MyClass { public: MyClass() { ++count; } ~MyClass() { --count; } static int getCount() { return count; } private: static int count; }; int MyClass::count=0; int main() { MyClass obj; cout<<obj.getCount(); MyClass *ptr=new MyClass; cout<<MyClass::getCount(); delete ptr; cout<<MyClass::getCount(); return 0; }程序的输出结果是A.121B.232C.221D.122

考题 有如下程序:includeusing namespace std;class Point{public: static int number; 有如下程序:#include<iostream>using namespace std;class Point{public: static int number;public: Point(){number++;} ~Point(){number--;}};int Point::number=0;void main(){ Point*ptr; Point A,B; { Point*ptr_point=new Point[3]; ptr=pb_point; } Point C cout<<Point::number<<endl; delete[]ptr; }运行时输出的结果是A.3B.4C.6D.7

考题 main函数中发生编译错误的语句是______。 include class A { public: int a; const i main函数中发生编译错误的语句是______。include<iostream.h>class A{public:int a;const int b;A( ):a(10),b(20){}void fun( )const{cout<<"a="<<a<<"\tb="<<b<<endl;}};void main( ){A obj1;const A*ptr=new A;ptr=obj1;ptr->a=100;ptr->fun( );}

考题 下列程序的输出结果是______。includeusing namespace std;int main() {char a []="He 下列程序的输出结果是______。 #include<iostream> using namespace std; int main() { char a []="Hello, World"; char *ptr=a; while (* ptr) { if(*ptr)= 'a' *ptr' <= 'z') cout << char(*ptr+'A'-'a'); else cout << *ptr; ptr++; } return 0; }A.HELLO,WORLDB.Hello,WorldC.hELLO, wORLDD.hello,world

考题 下面程序的输出结果是( )。 include main() {static char a[]="china"; char*ptr=a; whi 下面程序的输出结果是( )。 include<stdio.h> main() {static char a[]="china"; char*ptr=a; while(*ptr) {printf("%c",*ptr-32); ptr++; } }

考题 有如下程序:includeusing namespace std;elass MyClass{public:MyClass( ){++count; 有如下程序: #include<lostreanl> using namespace std; elass MyClass{ public: MyClass( ){++count;} ~MyClass( ){--count;} static int getCount( ){return count;} private: static int count; }; int MyClass::count=0; int main( ){ MyClass obj; cout<<obj.getCount( ); MyClass*ptr=new MyClass; cout<<MyClass::getCount( ); delete ptr; cout<<MyCiass::getCount( ); return 0; } 程序的输出结果是A.121B.232C.221D.122

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

考题 下列有关指针的用法中错误的是( )。A.int i;int *ptr=i;B.inti;int *ptr;i=*ptr;C.int *ptr;ptr=0;D.int i=5;int *ptr;*ptri;

考题 下列程序中需要清理动态分配的数组,划线处应有的语句是_______。 include class pers 下列程序中需要清理动态分配的数组,划线处应有的语句是_______。include<iostream.h>class person{int age,tall;public:person( ){age=0;tall=40;cout<<"A baby is born."<<endl;}person(int i){age=i;tall=40;cout<<"A old person."<<endl;}person(int i,int j){age=i;tall=j;cout<<"a old person with tall."<<endl;)~person( ){cout<<"person dead."<<endl;}void show( ){cout<<"age="<<age<<",tall="<<tall<<endl;}};void main( ){person*ptr;ptr=new person[3];ptr[0]=person( );ptr[1]=person(18);ptr[2]=person(20,120);for(int i=0;i<3;i++)ptr[i].show( );______}

考题 下面程序的输出结果是______。main(){ static char a[]="language",b[]="program";char *ptrl=a,*ptr2=b;int kfor(k=0;k<7;k++)if(*(ptrl+k)==*(ptr2+k))printf("%c",*(ptr1+k));}

考题 有如下程序: #inCludeiostream using namespaCe std; Class Base{ publiC: void output{Cout1;} virtual void Print{CoutB’;} }; Class Derived:publiC Base{ publiC: void output{Cout2;} void Print{Cout’D ;} }; int main { Base * ptr=new Derived; ptr一output; ptr一Print; delete ptr; retum0; } 执行这个程序的输出结果是( )。A.1BB.lDC.2BD.2D

考题 下面程序的输出结果是( )。 include main(){static chara[]="zhao",b[]="juan"; char*pt 下面程序的输出结果是( )。 include<stdio.h> main() {static chara[]="zhao",b[]="juan"; char*ptr1=a,*ptr2=b; int k; for(k=0;k<4;k++) if(*(ptr1+k)==*(ptr2+k)) printf("%c",*(ptr1+k));}

考题 有以下程序:include main( ){int a[3][2]={0} ,( *ptr)[2],i,j;for(i=0;i 有以下程序: #include <stdio.h> main( ) { int a[3][2]={0} ,( *ptr)[2],i,j; for(i=0;i<2;i++) {ptr=a+i; scanf("%d",ptr); ptr++;} for(i =0;i<3;i ++ ) } for(j =0;j<2;j ++ ) prinff( "%2d" ,a[i] [j] ); prinff(" \n" ); }}若运行时输入:1 2 3 <回车>,则输出结果是( )。A.产生错误信息B.10 20 00C.12 30 00D.10 20 30

考题 有如下程序: #inCludeiostream using namespaCe std; Class Point{ publiC: statiC int number; publiC: Point( )t.number++;} ~Point( ){number--;} }; , int P0int::number=0; int main( ){ Point *ptr: Point A,B; Point*ptr_point=new Point[3]; ptr=ptr_point;’ } Point C; CoutPoint:::numberendl; delete[]ptr; return 0; } 执行这个程序的输出结果是( )。A.3B.4C.6D.7

考题 以下程序执行结果是 ( )。include class Base{public virtual void fun() {cout 以下程序执行结果是 ( )。 #include <iostream.h> class Base { public virtual void fun() { cout<<"B"; } }; class Derived { public: Derived() { cout<<"D"; } virtual void fun(){ Base::fun(); cout<<"C"; } } int main () { Base *ptr; Derived obj; ptr=obj; p->fun ( ); return 0; }A.DBCB.DCBC.BDCD.CBD

考题 分析下列程序,并写出运行结果【】。 include voidmain(){ int x[10]: int i=5,*ptr=x; 分析下列程序,并写出运行结果【 】。include<iostream.h>void main(){int x[10]:int i=5,*ptr=x;*(ptr+i)=10;cout<<x[i]<<end1;

考题 下列有关指针的用法中错误的是( )。A.int i;int*ptr=i;B.int i;int*ptr;i=*ptr;C.int*ptr;ptr=0;D.int i=5;int*ptr;*ptri;

考题 在下面程序运行includeint func(char s[]){ int length=0; while(*(s+length))leng 在下面程序运行 #include<iostream.h> int func(char s[]){ int length=0; while(*(s+length))length++; return length; } void main(){ char a[10], *ptr=a; cin>>ptr; cout<<fune(ptr)<<end1; } 如果输入字符串Hello!并回车,则输出结果为 ______。A.4B.7C.6D.5

考题 有如下程序: #inCludeiostream using namespaCe耐: Class MyClass{ publiC: MyClass{++Count;} ~MyClass{--Count;} statiC int getCount{retum Count;} private: statiC int Count; }; ‘ int MyClass::Count=0; int main { MyClass obj; Coutobj.getCount; MyClass+ptr=new MyClass: CoutMyClass::9etCount; ’delete ptr; CoutMyClass::9etCount; return 0; } 执行这个程序的输出结果是( )。A.121B.232C.221D.122

考题 有如下程序:include using namespace std;class shapes{protected: int x, y;public: 有如下程序: #include <iostream> using namespace std; class shapes { protected: int x, y; public: void setvalue(int d, int w=O) { x=d; y=w; } virtual void disp()=O; }; class square : public shapes { public: void disp () { cout<<x*y<<end1; } }; int main ( ) { shapes *ptr; square s1; ptr=s1; ptr->setvalue (10, 5) ;ptr->disp(); return 0; } 执行上面的程序将输出( )。A.50B.5C.10D.15

考题 下列程序的输出结果是 include usingnamespacestd; int main () {chara []="Hello,W 下列程序的输出结果是 #include <iostream> using namespace std; int main () { char a [] = "Hello,World": char*ptr = a; while (*ptr) { if(*ptr>= 'a' *ptr <='z' cout<<char{*ptr+'A'-'a'); else cout<<*ptr; ptr++; } return 0; }A. HELLO. WORLDB. Hello, WorldC. hELLO, wORLDD. hello, world

考题 单选题有如下程序 #include main() {  inti,*ptr;  intarray[5]={5,3,1};  for(ptr=array,i=0;i5;i++,ptr++)  {   if(*ptr==0)    putchar('X');   else    putchar('A'+*ptr);  }  printf(""); } 程序运行后的输出结果是(  )。A FDBXXB FFFXXC FDBBBD ABCDE

考题 单选题有如下程序:#include main(){ int i,*ptr; int array[3]={8,2,4}; for(ptr=array,i=0;i  printf("%d,",*ptr++); printf("");}程序运行后的输出结果是(  )。A 8,2,B 8,8,C 2,4,D 4,8,