阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。
说明
以下程序的功能是计算三角形、矩形和正方形的面积并输出。
程序由4个类组成:类Triangle、Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述三种图形面积的通用接口。
c++程序
include <iostream.h>
inclule <math.h>
class Figure {
public:
virtual double getArea()= 0; // 纯虚拟函数
};
class Rectangle: (1) {
protected:
double height;
double width;
public:
Rectangle() { };
Rectangle(double height, double width) {
this->height = height;
this->width = width;
}
double getArea() {
return (2) ;
}
class Square: (3) {
public:
Square(double width) {
(4) ;
}
};
class Triangle: (5) {
double la;
double lb;
double lc;
public:
Triangle(double la, double lb, double lc) {
this->la = la; this->lb ='lb; this->lc = lc;
}
double getArea() {
double s = (la+lb+lc)/2.0;
return sqrt(s*(s-la)*(s-lb)*(s-lc));
} }; void main() {
Figure* figures[3] = {
new Triangle(2,3,3), new Rectangle(5,8), new Square(5)};
for (int i = 0; i < 3; i++) {
com << "figures[" << i << "] area =" << (figures[i])->getArea0 << endl;
}
第1题:
●试题二
阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
该程序运行后,输出下面的数字金字塔

【程序】
include<stdio.h>
main ()
{char max,next;
int i;
for(max=′1′;max<=′9′;max++)
{for(i=1;i<=20- (1) ;++i)
printf(" ");
for(next= (2) ;next<= (3) ;next++)
printf("%c",next);
for(next= (4) ;next>= (5) ;next--)
printf("%c",next);
printf("\n");
}
}
第2题:
(a)智能网概念模型中分布功能平面模型如下图所示,请根据此图将应填入(n)处的 字句写在答题纸的对应栏内。

第3题:
第4题:
试题三(共 15 分)
阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。

第5题:
第6题:

