●试题七阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。【说明】设计一个评选优秀教师和学生的程序,其类结构如图6所示。当输入一系列教师或学生的记录后,将优秀学生及教师的姓名列出来。图6【程序】includeiostream.hincludestdio.henum boolean{False,True};class base{protected:char name[8];public:void getname(){cout"姓名:";cinname;}void printname(){cout"姓名:"nameendU3virtual boolean isgood()=0;}class student: (1){int num;public:void getnum(){cout"考试成绩:"; cinnum;}boolean isgood(){return (2) ;}};class teacher: (3) public base{int num;public:void getnum(){cout"每年发表论文数:";cinnum;}boolean isgood(){return (4) ;}};void main(){base*p[50 ];student*pstud;teacher*ptech;char ch;int count=0;do{cout"输入教师(t)或学生(s):";cinch;if(ch==′s′){pstud=new student;pstud-getname();pstud-getnum();p[count++]=pstud;}else if(ch==′t′){ptech=newteacher;ptech-getname();ptech-getnum();p[count++]=ptech;}elsecout"输入错误"endl;cout"继续输入吗(Y/n)";cinch;}while(ch==′y′);for(int i=0;icount;i++){if( (5) )∥若为优秀,则输出p[i]-printname();}}

●试题七

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

【说明】

设计一个评选优秀教师和学生的程序,其类结构如图6所示。当输入一系列教师或学生的记录后,将优秀学生及教师的姓名列出来。

图6

【程序】

include<iostream.h>

include<stdio.h>

enum boolean{False,True};

class base

{

protected:

char name[8];

public:

void getname(){cout<<"姓名:";cin>>name;}

void printname(){cout<<"姓名:"<<name<<endU3

virtual boolean isgood()=0;

}

class student: (1)

{

int num;

public:

void getnum()

{

cout<<"考试成绩:"; cin>>num;

}

boolean isgood(){return (2) ;}

};

class teacher: (3) public base

{

int num;

public:

void getnum()

{

cout<<"每年发表论文数:";cin>>num;

}

boolean isgood(){return (4) ;}

};

void main()

{

base*p[50 ];

student*pstud;

teacher*ptech;

char ch;

int count=0;

do

{

cout<<"输入教师(t)或学生(s):";

cin>>ch;

if(ch==′s′)

{

pstud=new student;

pstud->getname();

pstud->getnum();

p[count++]=pstud;

}

else if(ch==′t′)

{

ptech=newteacher;

ptech->getname();

ptech->getnum();

p[count++]=ptech;

}

else

cout<<"输入错误"<<endl;

cout<<"继续输入吗(Y/n)";

cin>>ch;

}while(ch==′y′);

for(int i=0;i<count;i++)

{

if( (5) )∥若为优秀,则输出

p[i]->printname();

}

}


相关考题:

阅读以下说明和C++码,将应填入(n)处的字名写在对应栏内。从下列的3道试题(试题五至试题七)中任选1道解答。如果解答的试题数超过1道,则题号小的1道解答有效。[说明] 编写程序,把从键盘上输入的一批整数(以-1作为终止输入的标志)保存到文本文件“a: xxk1. dat”中。(1)include <fstream. h >include < stdlib. h >void main ( ) {(2)if ( ! four) {cerr < <“文件没有找开!” < <end1;exit (1);}int x;cin > >x;while((3)){(4)cin> >x;}(5)}

阅读以下说明和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。

阅读下列说明和流程图,将应填入(n)的字句写在对应栏内。【说明】下列流程图(如图4所示)用泰勒(Taylor)展开式sinx=x-x3/3!+x5/5!-x7/7!+…+(-1)n×x2n+1/(2n+1)!+…【流程图】计算并打印sinx的近似值。其中用ε(>0)表示误差要求。

阅读下列程序说明和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)处的字句写在对应栏内。[函数2.1说明]下面程序的功能是计算x和y的最小公倍数。[函数2.1]main(){ int m,n,d,r;seanf("%d %d",m,n);if(m<n) {r=m;m=n;n=r;}(1);while (d%n! =0) (2);printf("%d\n",d);}[函数2.2说明]下述程序接收键盘输入,直到句点“.”时结束。输入的字符被原样输出,但连续的空格输入将转换成一个空格。[函数2.2]include <stdio.h>main(){ char c,preChar='\0';c = getchar();while(c! = '.'){if((3)) putchar(c);else if(preChar! =' ') putchar(c);(4);c=(5);}}

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】设计一个评选优秀教师和学生的程序,其类结构如图6所示。当输入一系列教师或学生的记录后,将优秀学生及教师的姓名列出来。【程序】include<iostream.h>include<stdio.h>enum boolean {False,True}class base{protected:char name[8];public:void getname() {cout<<"姓名:" ;cin>>name; }void printname() {cout<<"姓名:"<<name<<endU3virtual boolean isgood() =0;}class student:(1){int num;public:void getnum()cout<<"考试成绩:" cin>>num;boolean isgood() {return (2);{};class teacher:(3) public baseint num;public:void getnum()cout<<"每年发表论文数:" ;cin>>num;boolean isgood() {return (4);}};void main()base* p[50];student * pstud;teacher * ptech;char ch;int count =0;docout<<"输入教师(t)或学生(s):"cin>>ch;if(ch =='s'){pstud = new student;pstud ->getname();pstud ->getnum();p[count ++ ] = pstud;}else if(ch == 't'){ptech = newteacher;ptech - >getname( )ptech ->getnum();p[count++]=ptech;}elsecout<<"输入错误<<endl;cout<<"继续输入码(Y/n)";cin>>ch;} while(ch == 'y')for(int i=0;i<count;i++){if((5)) //若为优秀,则输出p[i]->printname();}}

阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。[说明]下面的流程图用于计算一个英文句子中最长单词的长度(即单词中字母个数)MAX。假设该英文句子中只含字母、空格和句点“.”,其中句点表示结尾,空格之间连续的字母串称为单词。[流程图]

阅读下列说明和c++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应着一个不同的灯。利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关,现采用Command(命令)模式实现该遥控器的软件部分。Command模式的类图如图5-1所示。【c++代码】}

阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应着一个不同的灯。利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关,现采用Command(命令)模式实现该遥控器的软件部分。command模式的类图如图6-1所示。【Java代码】}

●试题二阅读下列函数说明和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");}}

●试题一阅读下列说明和流程图,将应填入(n)的字句写在答题纸的对应栏内。【说明】下列流程图(如图4所示)用泰勒(Taylor)展开式sinx=x-x3/3!+x5/5!-x7/7!+…+(-1)n×x 2n+1/(2n+1)!+…【流程图】图4计算并打印sinx的近似值。其中用ε(0)表示误差要求。

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

阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。【说明】本程序用于评选优秀教师和学生。当输入一系列教师或学生的记录后,将优秀学生及教师的姓名列出来。其类结构如下图所示:【程序】include <iostream.h>include <stdio. h>class base{protected:char name[8];public:void getname(){cout<<"name:"; cin>>name;}void printname(){cout<<"name:"<<name<<endl;}(1)};class student: (2){int num;public:void getnum(){cout<<"score:"; cin>>num;}bool isgood(){return (3) }};class teacher: (2){int num;public:void getnum(){cout<<"paper:"; cin>>num;}bool isgood(){return (num>3)?true:false;}void main(){base *p[50];student *pstud;teacher *ptech;char ch;int count=0;do{cout<<"input teacher(t) or student(s):";cin>>ch;if(ch=='s'){pstud=new student;pstud->getname();pstud->getnum();p[count++]=pstud;}else if(ch=='t'){(4)ptech->getname();ptech->getnum();p[count++]=ptech;}elsecout<<"input is wrong"<<endl;cout<<"continue to iput(y/n)?";cin>>ch;}while(ch=='y');for(int i=0;i<count;i++)if((5))p[i]->printname();}

(a)智能网概念模型中分布功能平面模型如下图所示,请根据此图将应填入(n)处的 字句写在答题纸的对应栏内。

()阅读下列说明和C语言程序,将应填入 (n)处的语句写在答题纸的对应栏内。[说明]下面程序是一个带参数的主函数,其功能是显示在命令行中输入的文本文件内容。[C语言函数]#include"stdio.h"main(argc,argv) int argc; char *argv[]; { (1) ; if((fp=fopen(argv[1],”r’’))== (2) ) { printf(”file not open!\n”);exit(0);} while( (3) ) putchar( (4) ); (5); }

图6-1是下一代网络的体系结构简图,请根据此简图将应填入(n)处的字句写在答题纸的对应栏内。

阅读下列说明和 C ++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】某软件公司欲开发一款汽车竞速类游戏,需要模拟长轮胎和短轮胎急刹车时在路面上留 下的不同痕迹,并考虑后续能模拟更多种轮胎急刹车时的痕迹。现采用策略(Strategy)设计模式来实现该需求,所设计的类图如图 6-1 所示。【C++ 代码】#includeusing namespace std;class BrakeBehavior{public:(1) ; /*其余代码省略*/};class LongWheelBrake : public BrakeBehavior{public:void stop(){cout

阅读下列说明和C++-代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图5-1所示的类图。【C++代码】 #include using namespace std; class invoice{ public: (1){ cout

阅读下列说明,回答问题1和问题2,将解答写在答题纸的对应栏内。【说明】 Windows 系统的用户管理配置中,有多项安全设置,如图2-1 所示。

阅读下列说明和C++代码,回答问题,将解答填入答题纸的对应栏内。【说明】某航空公司的会员积分系统将其会员划分为:普卡 (Basic)、银卡(Silver)和金卡 (Gold) 三个等级。非会员 (NonMember) 可以申请成为普卡会员。会员的等级根据其一年内累积 的里程数进行调整。描述会员等级调整的状态图如图 5-1 所示。现采用状态 (State) 模式实现上述场景,得到如图 5-2 所示的类图。【问题1】(15分)阅读上述说明和C++代码,将应填入 (n) 处的字句写在答题纸的对应栏内。

阅读下列说明和 Java 代码,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 某软件公司欲开发一款汽车竞速类游戏,需要模拟长轮胎和短轮胎急刹车时在路面上 留 下的不同痕迹,并考虑后续能模拟更多种轮胎急刹车时的痕迹。现采用策略(Strategy) 设 计模式来实现该需求,所设计的类图如图 5-1 所示。

阅读下列说明和 Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】某航空公司的会员积分系统将其会员划分为:普卡 (Basic) 、银卡(Silver)和金卡 (Gold)三个等级。非会员 (NonMember)可以申请成为普卡会员。会员的等级根据其 一年内累积的里程数进行调整。描述会员等级调整的状态图如图 6-1 所示 。现采用状态 (State) 模式实现上述场景,得到如图 6-2 所示的类图。

阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】 某文件管理系统中定义了类OfficeDoc和DocExplorer,当类OfficeDoc发生变化时,类DocExplorer的所有对象都要更新其自身的状态,现采用观察者(Observer)设计模式来实现该需求,所设计的类图如图6-1所示。

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