填空题根据程序中的注释将下列缺失部分补充完整。
class Point{
int x, y; //点的x和y坐标
public:
Point(int xx=0,int yy=。):x(xx),y(yy){}
};
class Circle{
Point center;//圆心位置
int radius; //半径
public: //利用cx和cy分别初始化圆心的x和y坐标
Circle(int cx;int cy,int r):__【12】__,radius(r){}
void area(){cout<<3.14159*radius*radius<
填空题下面程序的功能是:将字符数组a中下标值为偶数的元素从小到大排列,其他元素不变。请填空。
#include<iostream.h>
#include<string.h>
main()
{
char a[]="clanguage",t; //一定是偶数个数
int i,j,k;
k=strlen(a);
for(i=0;i<=k-2;i+=2)
for(j=i+2;j<=k; j=j+2)
if({{U}} 【15】 {{/U}})
{
t=a[i];a[i]=a[j];a[j]=t;
}
cout<<a<<endl;
}
填空题一棵二叉树有10个度为1的结点,7个度为2的结点,则该二叉树共有______个结点。
填空题假定动态分配一个类型为Worker的具有n个元素的数组,并由P指向这个动态数组,如果要释放这个数组,则使用的语句为______。
填空题{{U}} 【5】 {{/U}}是从二维表列的方向进行的运算。
填空题有如下循环语句: for(int i=50;i>20;i-=2);cout<<i<<','; 运行时循环体的执行次数是______次。
填空题下面是用来计算n的阶乘的递归函数,请将该函数的定义补充完整。(注:阶乘的定义是n!cn*(n-1)*...*2*1)
unsigned fact(unsigned n)
{
if (n<=1)
return 1;
return{{U}} 【12】 {{/U}};
}
填空题假定用户没有给一个名字为Sample的类定义构造函数,则系统为其隐含定义的构造函数为 【8】 。
填空题类模板不同于函数模板,类模板只可用{{U}} 【14】 {{/U}}型参数。
填空题如下程序的输出结果是______。 #include<iostream> using namespace std; class Wages //“工资”类 double base; //基本工资 double bonus; //奖金 double tax; //税金 public: Wages(double CBase,double CBonus,doable CTax): base(CBase),bonus(CBonus),tax(CTax) double getPay( )const; //返回应付工资额 Wages operator+(Wages w)cons[; //重载加法 ; double Wages::getPay( )cons[return base+bonus-tax; Wages Wages::operator+(Wages w)constreturn Wages(base+w.base,bonus+w.bonus,tax+w.tax); int main( ) Wages wl(2000,500,100),w2(5000,1000,300); eout<<(wl+w2).getPay( )<<endl; return 0;
填空题设有定义语句:int a=12;,则表达式a*=2+3的运算结果是{{U}} 【6】 {{/U}}。
填空题求1~100的和,可写成“for(s=0,i=1;
________
;i++) s+=i;”的形式。
填空题下面程序的运行结果为{{U}} 【10】 {{/U}}。
class A
} public:
int num;
A(int i){num=i;}
A(A &a){num=++a.num;}
void print(){cout<<num;}
};
void main(){
A a(1),b(a);
a.print();
b.print();
}
填空题下列程序的运行结果是{{U}} [12] {{/U}}。
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 ();
}
填空题下面程序的运行结果是 【9】 。 #include <iostream> using namespace std; class count static int n; public: count() n++; static int test() for(int i=0;i<4;i++) n++; return n; ; int count::n = O; int main() cout<<count:: test()<<" "; count c1, c2; cout<<count:: test()<<endl; return 0;
填空题数据模型按不同应用层次分为3种类型,它们是概念数据模型, 【1】 和物理数据模型。
填空题广义表的深度是指{{U}} 【2】 {{/U}}。
填空题从键盘上输入XXYYZZXYZWXP和X,以下程序的输出结果是 [9] 。 #include<iostream.h> #include<string.h> void main() char*str,ch; int count=0,pos; cin>>str>>ch; pos=strlen(str)-1; while(pos>=0) if((str[pos])=ch)count++; pos--; cout<<"count="<<count;
填空题下列程序的定义语句中,x[1]的初值是______,程序运行后输出的内容是______。 #include<stdio.h> void main() int x[]=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16),*p[4],i; for(i=0;i<4;i++) p[i]=&x[2*i+1]; printf("%d",p[i][0]); printf("/n")
填空题阅读以下程序,此程序的功能是{{U}} [8] {{/U}}。
#include<iostream.h>
void main()
{
int n, i, j;
for(i=100;i<999; i+100)
for(j=i/100:j<=99;j=j+10)
{
n=i+j;
cout<<" "<<n;
}
cout<<"/n";
}
