
有下列程序: #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.0
B.9
C.6
D.8

A.0
B.9
C.6
D.8
第1题
有下列程序,在横线添加; #include<iostream> using namespace std; class TestClass { public: TestClass (int n){number=n;} ______//拷贝构造函数 ~TestClass(){} private: int number; }; TestClass fun(TestClass p) { TestClass temp(P); return temp; } int main() { TestClsss obj1(10),obj2(0); TestClass obj3(obj1); obj2=fun(obj3); return 0; }
A.TestClass(TestClass &other){number=other.number;}
B.TestClass(TestClass other){number=other.number;}
C.TestClass(TestClass &other){number;}
D.TestClass(&other){number=other.number;}
第2题
有如下程序: #include<iostream> using namespace std; int main() { cout.fill('*') cout.width(6); cout.fill('#') cout<<123<<endl; return 0; } 执行后的输出结果是
A.###123
B.123###
C.***123
D.123***
第3题
有下列程序,功能是把输入的十进制长整型数以十六进制的形式输出,完成程序
#include "stdio.h"
main()
{char b[17]={"0123456789ABCDEF"};
int c[50],d,i=0,base=16;
long n;
scanf("%ld",&n);
do{c[i]=n%base;i++;n= 【14】 ;}
while(n!=0);
for(--i;i>=0;--i)
{d= 【15】 ;printf("%c",b[d]);}
printf("H\n");}
第4题
有如下程序: #include<iostream> using namespqce Std; class TestClass { private; Char C; public; TestClass(char n):c(n){} ~TestClass() { cout<<c; }; class TestClassl:public TestClass { private: Char C; public:
A.xy
B.yx
C.x
D.y
第5题
下列程序的输出结果是()。 #include<iostream> using namespace std; int main() { char a[]="Hello,Test"; char *p=a; while(*p) { if(*p>='a'&&*p<='z') cout<<char(*p+'A'-'a'); else cout<<*p; p++; } return 0; }
A.hello,test
B.Hello,Test
C.HELLO,TEST
D.hELLO,tEST
第6题
有如下程序: #include<iostream.h> using namespace std; Class Base { public: Base(){cout<<“BB”;f();} void{(){cout<<“BF”;} }; class Derived:public Base { public: Derived(){cout<<“DD”;} void f(){cout<<“Df”;) }; int main
A.BBBfDD
B.BBDfDDDf
C.DD
D.DDBBBf
第7题
有如下程序: #include<iostream> using namespace std; class Con { char ID; public: Con():ID('A'){cout<<1;} Con(char ID):ID(ID'){cout<<2;} Con(Con&c):ID(c.getID()){cout<<3;} char getID()const{returnID;} }; void show(Con c){to
A.13A23A
B.23A13B
C.13A23B
D.13B23A
第8题
有如下程序: #include<iostream> using namespace std; Class TestClass { private: int x,y; public: TestClass(int i,int j) { x=i; y=j; } void print() { cout<<“print1”<<endl; } void print()const { cout<<”prin
A.printl
B.print2
C.printl print2
D.程序编译时出错。
第9题
下列程序的输出结果是()。 #include<iostream> using namespace std; int main() 于 chara[]=”Hello,Test”; Char*p=a; while(*p) { if(*p)=’a’&&*p(=’z’) cout<<char(*p+’A’-’a’); else cout<<*p; p++; } return 0; }
A.hello,test
B.Hello,Test
C.HELLO,TEST
D.hELLO,tEST
第10题
有如下程序: #include<iostream.h> Using namespace std; Class Demo { public: Demo(){ cout<<“default constructor\n”;} Demo(const Demo &x){ cont<<“copy constructor\n”;} }; Demo usercode(Demob){Demo c(b);return c;} int main() {
A.1和1
B.1和2
C.2和3
D.2和4
第11题
有如下程序: #inClude<iostream> using namespace std; Class TestClass {public: virtUal void furll() {cout<<“funlTestclass”;} virtual void fun2() {cout<<“{fun2TestClass”;}}; class TestClassl:public TestClass {void fun() {cout<<“fu
A.fun1TestClass1 fun2TestClass
B.fun1TestClass1 fun2TestClass1
C.fUnlTestClass fun2TestClass
D.funlTe3tClass fun2TestClassl