填空题结构化程序设计思想的核心是要求程序只由顺序、循环和{{U}} [4] {{/U}}三种结构组成。
填空题以下程序的输出结果是{{U}} 【9】 {{/U}}。
#include<iostream>
using namespace std;
void fun()
{
static int a=0;
a+=2;
cout<<a;
}
int main()
{
int cc;
for(cc=1;cc<4;cc++)
fun();
cout<<end1;
return 0;
}
填空题已知程序的结果为1 2 3,请填空。
#include<iostream.h>
template<class T>
class A
{
public:
T X, y, z;
void display( ) {cout < < x < < " " < < y < < " " < < z;}
};
void main( )
{
A<int>a1;
{{U}} 12 {{/U}}
{{U}} 13 {{/U}}
{{U}} 14 {{/U}}
a1.display( ) ;
}
填空题以下函数用来求出数组的最大元素在数组中的下标并存放在k所指的存储单元中。请填空。
#include<iostream.h>
void fun(int * s,int t,int * k)
{ int i;
* k={{U}} 【9】 {{/U}};
{{U}} 【10】 {{/U}}
if(s[ * k] < s[i]) * k=i;}
void main( )
{ int a[l0]={ 876,675,896,101,301,401,980,431,451,777 },k;
fun(a,10,&k);
cout < < k < <"," < < a[k];}
填空题请定义一个函数名为A,返回值为int,没有参数的纯虚函数的定义是 。
填空题如下程序段的输出是______。
char c[20]="student";
c[3]=0;
cout<<c<<endl:
填空题含有纯虚函数的类称为______。
填空题以下程序的执行结果是 【12 。#include <iostream.h>class Bpublic:B()B(int i.int j); void printb();private:int a,b;;class Apublic:A() A(int i,int j);void printa();private:B c;;A:: A(int i,int j):c(i, j) void A:: pfinta()c. printb();B::B(int i,int j)a=i;b=j;void B::printb()cout<<"a="<<a<<",b="<<b<<end1;void main()A m(7,9);m. printa();
填空题有如下程序:
#include<iostream>
using namespace std;
class Base{
public:
int m,n;
};
class Derived1: _______【 】 Base{};
class Derived2:public Derived1{
public:
void SetMN(int M,int N){m=M;n=N;}
int GetSumMN(){return(m+n);}
};
int main() {
Derived2 objD;
ohjD. SetMN(3,4);
cout<<"M+N="<<objD, m+objD, n<<endl;
return 0
}
编译时只有“cout<<"M+N"<<objD.m+objD.n<<endl;”有语法错误,程序的其他地方没有语法错误。请判断下划线处使用的关键字是什么。
填空题语句int * i;i=new int [10];,释放指针i的语句是【 】。
填空题人员基本信息一般包括:身份证号,姓名,性别,年龄等。其中可以作为主关键字的是{{U}} 【5】 {{/U}}。
填空题软件工程包括3个要素,分别为方法、工具和{{U}} 【4】 {{/U}}。
填空题请在下列程序中的空格处填写正确的语句: class Sample public: Sample( ) ~Sample( ) void SetData(int datA) //将Sample类成员变量data设置成形参的值 ______ private: int data; ;
填空题派生类的成员一般分为两部分,一部分是【 】,另一部分是自己定义的新成员。
填空题有以下程序:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
fstream file;
file.open("abc.txt", ios_base::in);
if (! file )
{
cout<<"Can not open abc.txt"<<end1;
abort();
}
char ch;
int i = 0;
while ( ! file.eof() )
{
file.get(ch);
i++;
}
cout<<"Characters : "<<i<<end1;
file.close();
return 0;
}
程序实现的功能是{{U}} 【15】 {{/U}}。
填空题在下面横线上填上适当的语句,完成程序。 #include<iostream> using namespace std; class Base int x; public: Base(int i)x=i; ~Base() ; class Derived:public Base public: 【10】 完成类Derive构造函数的定义 ; int main() Derived Obj; return 0;
填空题写出执行完下列代码段之后指定变量的值:
bool x=true,y=false,z=false;
x=x&&y‖z;
y=x‖y&&z;
z=!(x!=y)‖(y==z);
则x=false,y=false,z={{U}} {{U}} {{/U}} {{/U}}。
填空题在用class定义一个类时,数据成员和成员函数默认的访问权限是{{U}} 【10】 {{/U}}:
填空题下列程序的输出结果为2,请将程序补充完整。
#include <iostream>
using namespace std;
class Base
{
public:
{{U}} 【12】 {{/U}}void fun() {cout<<1;}
};
class Derived: public Base
{
public:
void fun() {cout<<2; }
};
int main()
{
Base *p=new Derived;
p->fun();
delete p;
return 0;
}
填空题在下面程序横线处填上适当内容,使得程序的输出为9876。
#include <iostream>
using namespace std;
template<class T>
void f({{U}} 【12】 {{/U}})
{
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;
}
