阅读以下说明和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();}}

阅读以下说明和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<<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)处的字句写在对应栏内。【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中的元素按值非递减排列。程序流程图如下所示:

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。[说明]本程序中预设了若干个用户名和口令。用户输入正确的用户名后,可以查找对应的口令,一旦输入结束标记“end”,程序结束。[C++程序]include <iostream. h>include <string. h>class User{ protected:char user[10];char pass[7];public:User(char[ ],char[]);(1) {return user;}(2) {return pass;}};User::User(char u[],char p[]){ strcpy(user,u);strcpy(pass,p); }void main(){ User ua[]={User("Li","123456"),User("wang","654321"),User("Song","666666")char name[10];while(1)cout< < "输入用户名:";cin> >name;if((3)= =0) break;for(int i=0;i<3;i+ +)if(strcmp(name,ua[i].getuser()) = =0){cout< <"密码:" < < ua[i].getpass() < <endl;(4);if((5))cout< <"该用户不存在!" < <endl;}}

阅读下列程序说明和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)处的字句写在答题纸的对应栏内。【说明】设计一个评选优秀教师和学生的程序,其类结构如图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();}}

试题三(共 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();}

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

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