填空题在下面程序横线处填上适当内容,使得程序的输出为9876。 #include <iostream> using namespace std; template<class T> void f( 【12】 ) T t; for (int i=0;i<n/2;i++) t=a Ii]; a [i]=a[n-1-i]; a [n-1-i]=t; int main ( ) int x[]=6,7,8,9; f(x,4); for (int i=0;i<4;i++) cout<<x[i]; cout<<end1; return 0;
填空题下列for语句的循环次数为______。
For(nt a=0,b=1;b&&a<5;a++);
填空题当循环队列非空且队尾指针等于队头指针时,说明循环队列已满,不能进行人队运算。这种情况称为 【14】 。
填空题对长度为n的线性表进行冒泡排序,最坏情况下需要比较的次数为{{U}} 【5】 {{/U}}。
填空题下面程序的输出结果是 【7】 。#include<iostream.h>int add(int a, int b);void main()extern int x, y;cout<<add(x, y)<<end1;int x(20),y(5);int add(int a, int b)int s=a+ b;return s;
填空题有如下程序:
#inClude<iostream>
using namespace std;
class AA
{
public:
viltual void f()
{
cout<<"AA";
}
};
class BB:public AA
{
public:
BB()
{
cout<<"BB";
}
};
class CC:public BB
{
public:
virtual void f()
{
BB::f();
cout<<"CC";
}
};
int main()
{
AA aa,*p;BB bb;CC cc;
p=&cc;
p->f();
return 0;
}
运行后的输出结果{{U}} {{U}} {{/U}} {{/U}}。
填空题执行下列语句后,输出的结果为______。 void run() static int x=3; x++; cout<<x<<" "; int main() for(int i=0;i<2;i++) fun(); return D;
填空题表达式cout<<'/n'还可表示为{{U}} 【6】 {{/U}}。
填空题软件开发环境是全面支持软件开发全过程的 集合。
填空题下面程序的执行结果是______。 #include <iostream.h> void main() int n=0,x=0; do n++; if(n%3==2 while(x!=1); cout<<"n="<<n<<endl;
填空题运算符“+”允许重载为类成员函数,或者非成员函数。若用operator+(c1, c2)这样的表达式来使用运算符“+”,应将“+”重载为_【8】_函数。
填空题
【14】20【命题目的】模板函数的运用。【解题要点】要理解 * data的含意。
填空题C++语句const char *const p="hello";,所定义的指针p和它所指的内容都不能被______。
填空题以下程序的输出结果是{{U}} {{/U}}。
#include<iostream.h>
void main( )
{ int a=0;
a+=(a=8) ;
cout < < a;
}
填空题下列程序的运行结果是______。 #include<iostream.h> class Base public: void f(int x)cout<<“Base:”<<x<<endl; ); class Derived:public Base public: void f(char*str)cout<<“Derived:”<<str<<endl; ; void main(void) Base*pd=new Base; pd=new Derived; pd->f(‘a’);
填空题有如下的程序:
#include <iostream>
#include <cstring>
using namespace std;
class rev{
char*s;
public:
rev(const char*s){
this->s=new char[strlen(s)+1];
strcpy(this->s,s);
}
rev(rev
for(int i=0;i<strlen(r.s);i++)s[i]=r.s[strlen(r.s)-1-i];
s[strlen(r.s)]=0;
}
~rev() {delete s;}
friend ostream
};
ostreami>=0;i--) os<<c.s[i];
return os;
}
int main() {
char *p="Hello,world!";
rev hay("Hay!");
cout<<rev(p)<<endl;
cout<<rev(hay);
return0;
}
执行上面的程序将输出______。
填空题以下程序的执行结果是______
#include<iostrearn.h>
int f(int b[],int n)
{
int i,r=l;
for(i=0;i<n;i++)
r=r*b[i];
return r;
}
void main()
{
int x,a[]= {2,3,4,5,6,7,8,9};
x=f(a,3):
cout<<x<<endl;
}
填空题请在横线处填写派生类Derived的继承方式,使得程序的输出结果为Base。 #include<iostream> using namespace std; class Base public: void print() cout<<"Base"; ; ClaSS Derived: Base; int main() Derived d; d.print(); return 0;
填空题补充完整下面的类定义: const double PI=3.14; class Circle //圆形物体的抽象基类 protected: double r; //半径 public: Circle(double radius=0):r(radius) (13) ; //计算圆形物体表面积的纯虚函数声明 ; class Cylinder:public Circle //圆柱体类 double h; //高度 public: Cylinder(double radius=0,double height=0); Circle(radius),h(height) Virtual double Area( )return 2*PI*r*(r+h); //计算圆柱体的表面积 ;
填空题软件结构是以 【4】 为基础而组成的一种控制层次结构。
