阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。[说明]下面程序是为汽车市场编制的一个程序的一部分。其中automobile是基类。[C++程序]//Auto.hifndef AUTO_Hdefine AUTO_Hclass automobile{(1):int miles_per_gallon; //汽车每加仑行驶公里数float fuel_capacity; //油箱容积public:void initialize(int in_mpg,int in_fuel);int get_mpg(void);float get_fuel(void);float travel_distance(void);}endif//Auto.cppinclude"auto.h"void automobile::initialize(int in_mpg,float in fuel){miles_per_gallon=in_mpg;fuel_capacity=in_fuel;)int automobile::get_mpg() //提供一辆特定汽车每加仑公里数{return miles per_gallon;}float automobile::get_fuel() //提供油箱容积{return fuel_capacity;}float automobile::travel_distance(){return (2) }//car.hifndef CAR_Hdefine CAR_Hinclude"auto.h"class car: (3){int Total_doors;public:void initialize(int in_mpg,float in_fuel,int doors=4);int doors(void);};endif//car.cppinclude"car.h"void car::initialize(int in_mpg,float in_fuel,int door){Total_doors=door;miles_per_galion=in_mpg;fuel_capacity=in_fuel;}int car::doors(void){return Total doors;}//Allauto.cppincludeinclude"auto.h"include"car.h"int main(){car sedan;sedan.initialize(24,20.0,4);tout<<"The sedan can travel"<< (4) <<"miles.\n";cout<<"The sedan has"<< (5) <<"doors.\n";return 0;}

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。

[说明]

下面程序是为汽车市场编制的一个程序的一部分。其中automobile是基类。

[C++程序]

//Auto.h

ifndef AUTO_H

define AUTO_H

class automobile

{

(1):

int miles_per_gallon; //汽车每加仑行驶公里数

float fuel_capacity; //油箱容积

public:

void initialize(int in_mpg,int in_fuel);

int get_mpg(void);

float get_fuel(void);

float travel_distance(void);

}

endif

//Auto.cpp

include"auto.h"

void automobile::initialize(int in_mpg,float in fuel)

{

miles_per_gallon=in_mpg;

fuel_capacity=in_fuel;

)

int automobile::get_mpg() //提供一辆特定汽车每加仑公里数

{return miles per_gallon;}

float automobile::get_fuel() //提供油箱容积

{return fuel_capacity;}

float automobile::travel_distance()

{return (2) }

//car.h

ifndef CAR_H

define CAR_H

include"auto.h"

class car: (3)

{

int Total_doors;

public:

void initialize(int in_mpg,float in_fuel,int doors=4);

int doors(void);

};

endif

//car.cpp

include"car.h"

void car::initialize(int in_mpg,float in_fuel,int door)

{

Total_doors=door;

miles_per_galion=in_mpg;

fuel_capacity=in_fuel;

}

int car::doors(void)

{return Total doors;}

//Allauto.cpp

include

include"auto.h"

include"car.h"

int main()

{

car sedan;

sedan.initialize(24,20.0,4);

tout<<"The sedan can travel"<< (4) <<"miles.\n";

cout<<"The sedan has"<< (5) <<"doors.\n";

return 0;

}


相关考题:

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【C++程序】include include 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【C++程序】include < stdio. h >include < string. h >define Max 1000class Bank{int index;char date [Max] [10]; // 记录交易日iht amount[Max]; // 记录每次交易金额,以符号区分存钱和取钱int rest[ Max]; // 记录每次交易后余额static iht sum; // 账户累计余额public:Bank( ) {index =0;}void deposit( char d[ ] , int m) //存入交易{strcpy ( date [ index ], d);amount[ index] = m;(1);rest[ index] = sum;index++;}void withdraw (char d[ ], int m) //取出交易{strcpy( date[ index] ,d);(2);(3);rest[ index] = sum;index++;}void display( );};int Bank:: sum = 0;void Bank:: display ( ) //输出流水{int i;printf("日期 存入 取出 余额\n");for (4){printf(" %8s" ,date[i] );if (5)printf(" %6d" , -amount[i] );elseprintf( "%6d ",amount[i] );printf( "% 6d\n" ,rest[i] );} }void main( ){Bank object;object. deposit ( "2006.2.5", 1 00 );object. deposit( "2006.3.2" , 200);object. withdraw( "2006.4.1", 50);object. withdraw( "2006.4.5", 80);object. display ( );}本程序的执行结果如下:日期 存入 取出 余额 2006.2.5 100 1002006.3.2 200 3002006.4.1 50 2502006.4.5 80 170

阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。【说明】已知头指针分别为La和lb的有序单链表,其数据元素都是按值非递减排列。现要归并La和Lb得到单链表Lc,使得Lc中的元素按值非递减排列。程序流程图如下所示:

阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。【说明】以下程序为求行列式X(5,5)的值S。【Visual Basic代码】Private Function col ( byval x ( 5,5 ) as integer ) as longdim fesult as longdim temp as longdim I as integerdim j as integerdim k as imegerresult = 0for I = to 5(1)for j = 1 to 5if I+j>6 thenk= ( 1+j ) mod 5elsek=1endiftemp=temp*x ( k,j )(2)result=(3)(4)(5)End function

阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。[说明]设学生某次考试的成绩按学号顺序逐行存放于某文件中,文件以单行句点“.”为结束符。下面的流程图读取该文件,统计出全部成绩中的最高分max和最低分min。

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。[说明]下面程序实现十进制向其它进制的转换。[C++程序]include"ioStream.h"include"math.h"includetypedef struct node {int data;node*next;}Node;Class Transform.{DUDlic:void Trans(int d,int i); //d为数字;i为进制void print();private:Node*top;};void Transform.:Trans(int d,int i){int m,n=0;Node*P;while(d>0){(1);d=d/i;p=new Node;if(!n){p->data=m;(2);(3);n++;}else{p->data=m;(4);(5);}}}void Transform.:print(){Node*P;while(top!=NULL){p=top;if(p->data>9)cout<<data+55;elsecout<<data;top=p->next;delete p;}}

阅读以下说明,以及用C++在开发过程中所编写的程序代码,将应填入(n)处的字句写在对应栏内。【说明】在下面函数横线处填上适当的字句,使其输出结果为:构造函数.构造函数.1,25,6析构函数析构函数.【C++代码】include "iostream.h"class AA{ public;AA(int i,int j){A=i; B=j;cout<<"构造函数.\n";}~AA(){(1);}void print();private:int A, B;};void AA∷print(){cout<<A<<","<<B<<endl;}void main(){AA *a1, *a2;(2)=new AA(1, 2);a2=new AA(5, 6);(3);a2->print();(4) a1;(5) a2;}

阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写在对应栏内。【说明】阅读下面几段C++程序回答相应问题。比较下面两段程序的优缺点。①for (i=0; i<N; i++ ){if (condition)//DoSomething…else//DoOtherthing…}②if (condition) {for (i =0; i<N; i++ )//DoSomething}else {for (i=0; i <N; i++ )//DoOtherthing…}

●试题二阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】该程序运行后,输出下面的数字金字塔【程序】includestdio.hmain (){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");}}

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

阅读下列说明和?C++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】阅读下列说明和?Java代码,将应填入?(n)?处的字句写在答题纸的对应栏内。【说明】某快餐厅主要制作并出售儿童套餐,一般包括主餐(各类比萨)、饮料和玩具,其餐品种类可能不同,但其制作过程相同。前台服务员?(Waiter)?调度厨师制作套餐。现采用生成器?(Builder)?模式实现制作过程,得到如图?6-1?所示的类图。