网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

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

}

else

cout<<"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();

}


参考答案

更多 “ 阅读以下说明和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();} ” 相关考题
考题 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。[说明]以下程序的功能是统计学生成绩,包括输入学生的姓名和成绩,按成绩从高到低排列打印输出,对前百分之七十的学生定为合格(PASS),而后百分之三十的学生定为不合格(FAIL)。例如,当输入4名学生的姓名和成绩“Alice 67 Mary 90 Tom 56 John 88”后,程序的执行结果如下:姓名 成绩 合格否Mary 90 PASSJohn 88 PASSAlice 67 FAILTom 56 FAIL[C++程序]include <stdio.h>include <string.h>define N 10class student{ protected:char name[10];int deg;public:void setname(charna[]) {strcpy(name,na);}char * getname() {return name;}void setdeg(int d) {deg= d;}int getdeg(){return deg;}};class compute{ int ns;student na[N];public:void getdata();void sort();void disp();};void compute::getdata(){ int i,tdeg;char tname[10];printf("输入学生人数:");scanf("%d",ns);printf("输入学生姓名和成绩:\n");for(i=0;i<ns;i+ +){scanf("%s%d",tname,tdeg);(1);na[i].setdeg(tdeg);}}void compute::sort(){ int i,j,pick;(2);for(i=0;i<ns-1;i+ +){pick=i;for(j=i+1;j<ns;j+ +)if(na[j].getdeg()>na[pick].getdeg()) (3);temp=na[i];na[i]=na[pick];na[pick]=temp;}}void compute::disp(){ int cutoff,i;printf("RESULT\n");printf("姓名 成绩 合格否\n");cutoff=ns*7/10-1;for(i=0;i<ns;i+ +) {printf("%-6s%3d",(4));if((5)) printf("\tPASS\n");else printf("\tFAIL\n");void main(){ compute obj;obj.getdata();obj.sort();obj.disp();}

考题 ●试题二阅读下列程序或函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【函数2.1说明】函数strcmp()是比较两个字符串s和t的大小。若s<t函数返回负数;若s=t函数返回0;若s>t,函数返回正数。【函数2.1】int strcmp(char *s,char *t){ while(*s *t (1) ){s++;t++;}return (2) ;}【程序2.2说明】在n行n列的矩阵中,每行都有最大的数,本程序求这n个最大数中的最小一个。【程序2.2】#includestdio.h#define N 100int a[N][N];void main(){ int row ,col,max,min,n;/*输入合法n(<100),和输入n×n个整数到数组a的代码略*/for (row=0;row<n;row++){for(max=a[row][0],col=1;col<n;col++)if( (3) )max=a[row][col];if( (4) )min=max;else if( (5) )min=max;}printf ("The min of max numbers is %d\n",min);}

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

考题 阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。【程序2.1说明】已知一个排好序的数组,现输入一个数,要求按原来的顺序规律,将它插入到数组中。【程序2.1】include <stdioh>define N 100void main(){float a[N+l],x;int i,p;printf("输入已经排好序的数列: ");for(i=0; i<N; i++)scanf(%f",a[i]);printf("输入要插入的数:");scanf("%f",x);for(i=0,p=N; i<N; i++)if(x<a[i]){(1)break;}for(i=N-1; i>=p; i--)(2)(3)for(i=0; i<=N; i++)prinff("%f\t",a[i]);}【程序2.2说明】本程序用变量count统计文件中字符的个数。【程序2.2】include <stdio.h>include <stdlib.h>void main(){FILE *fp;long count=0;if((fp=fopen("letter.txt","r"))==NULL){printf("can not open file\n");exit(0);}while(!feof(fp)){(4)count++;}printf("count=%d\n",count);(5)}

考题 阅读以下说明和流程图,将应填入(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;}}

考题 阅读以下说明和流程图,将应填入(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)处的字句写在对应栏内。【程序2.1说明】求所有满足如下条件的三位数:它除以11得的商等于它各位数字的平方和。例如 550,除以11商为50,50=52+52+02。【程序2.1】void main(){int i, j,n,s;for(i=100;i<=999;i++){n=i;j=n/11;s=0;while((1)){(2)n/=10;}if((3))printf("%d\t",i);}}【程序2.2说明】本程序输入一字符串,将其中的大写字母改变成小写字母。【程序2.2】void main(){int i=0;char s[120];scanf("%s",s);while((4)){if((5))s[i]=s[i]- 'A'+'a';i++;}printf("%s\n",s);}

考题 阅读下列程序说明和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();}}

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

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

考题 ●试题七阅读以下说明和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) 处的字句写在答题纸的对应栏内。

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

考题 下图是基于软交换的网络分层模型简图,请根据简图将应填入(n)处的字句写在答题 纸的对应栏内。(图中(6)是(4)与媒体网关交互时可以使用的控制协议)

考题 ()阅读下列说明和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

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

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

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

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