首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下列程序说明和C++代码,将应填入(n)处的字句写在对应栏内。 [说明] ①定义私有数据成员code、english分别用于表示考生的编号、英语成绩,它们都是int型的数据。 ②完成成员函数void Student::inputinf
阅读下列程序说明和C++代码,将应填入(n)处的字句写在对应栏内。 [说明] ①定义私有数据成员code、english分别用于表示考生的编号、英语成绩,它们都是int型的数据。 ②完成成员函数void Student::inputinf
admin
2009-02-15
16
问题
阅读下列程序说明和C++代码,将应填入(n)处的字句写在对应栏内。
[说明]
①定义私有数据成员code、english分别用于表示考生的编号、英语成绩,它们都是int型的数据。
②完成成员函数void Student::inputinformation()的定义,该函数用于用户输入一个考生对象的信息,输入格式如下:
输入编号:
英语成绩:
计算机成绩:
③利用已实现的类Student的成员函数,完成函数void firstname(Student *A[],int uum)的定义,该函数根据考生信息A[],输出num个考生中总分最高者的编号及其相应的总分,在此不考虑总分相同的情况。
源程序文件test1.cpp清单如下:
#include < iostream. h >
class Student
(1)
int computer;
int total;
public
void getinformation( );
void computesum( );
int getcode( );
int gettotalscore( );
~Student( );
};
void Student: :getinformation( )
{
(2)
cout <<"英语成绩:";
cin> >english;
cout <<"计算机成绩:";
cin > > computer;
void Student:: computesum ( )
total = english + computer;
cout <<"编号" << code <<"总分:" <<total << endl;
int Student::getcode( )
return code;
}
int Student:: gettotalscore ( )
{
return total;
}
void firstname(Student * A[] ,int num)
{
(3)
tempsum = ( * A[0] ). gettotalscore( );
for( int i=1; i <num; i++)
{
if ( ( ( * A
). gettotalscore( ) ) > tempsum)
{
tempcode = ( * A
). getcode( );
tempsum = ( * A
). gettotalscore( );
}
}
cout <<"总分最高者--" << tempcode <<":" << tempsum <<endl;
}
void main( )
{
Student * A[3];
int i,n =3
for(i=0;i<n;i ++)
A
= new Student;
A
-> getinformation( )
for(i=0;i<n;i ++)
{
A
-> computesum( )
firstname ( A,3 );
}
选项
答案
(1)itn code; int english; (2)cout<<"输入编号:"; cin>>code; (3)int tempcode, tempsum; tempcode=(*A[0]). getcode();
解析
本题是对C++程序设计的综合考查,其设计类的成员及成员函数的定义与调用,数据的输入输出,for循环语句,if条件判断语句等多个知识点,注意(3)中指针数组的使用,指针数组是一组指针,每一个成员都按照指针的操作规则,但是整个访问规则仍然使用数组下标方式,如A[0]指的是第一个指针,而*A[0]是取出第一个指针指向的内容。
转载请注明原文地址:https://kaotiyun.com/show/VgDZ777K
本试题收录于:
软件设计师下午应用技术考试题库软考中级分类
0
软件设计师下午应用技术考试
软考中级
相关试题推荐
以下关于用例图的叙述中,不正确的是(44)。图书馆管理系统需求中包含“还书”用例和“到书通知”用例,对于“还书”用例,应先查询该书是否有人预定,若有则执行“到书通知”。“还书”用例和“到书通知”用例是(45)关系,以下用例图中,(46)是正确的。管理员处
某教学管理数据库中,学生、课程关系模式和主键分别为:S(学号,姓名,性别,家庭住址,电话),关系S的主键为学号;C(课程号,课程名,学分),关系C的主键为课程号。假设一个学生可以选择多门课程,一门课程可以由多个学生选择。一旦学生选择某门课程必定有该课程的成
测试执行过程的阶段不包括______。
GB/T18905-2002《软件工程产品评价》中确定的通用评价过程包括四个方面,即:确立评价需求,规定评价,设计评价和执行评价,其中有关“规定评价”部分包含的内容有(52)。
假设实体集E1中的一个实体可与实体集E2中的多个实体相联系,E2中的一个实体只与E1中的一个实体相联系,那么E1和E2之间的联系类型为()。
设有关系模式R(A1,A2,A3,A4,A5,A6),其中:函数依赖集F={A1→A2,A1A3→A4,A5A6→A1,A2A5→A6,A3A5→A6),则___________(21)是关系模式R的一个主键,R规范化程度最高达到____________(
在分布式数据库中有分片透明、复制透明、位置透明和逻辑透明等基本概念,其中:___________(19)是指局部数据模型透明,即用户或应用程序无须知道局部使用的是哪种数据模型;___________(20)是指用户或应用程序不需要知道逻辑上访问的表具体是怎
在面向对象系统中,对象的属性是()。
Windows系统中,在排除DNS域名解析故障时,需要刷新DNS解析器缓存,使用的命令是______。
线性表采用单循环链表存储的主要优点是_______。
随机试题
《从军行》之题名,原属于汉乐府()
在起重设备上的绕线式异步电动机常采用的起动方式是()。
某生产企业为增值税一般纳税人,同时生产免税货物甲(以下简称货物甲)和应税货物乙(以下简称货物乙),2014年4月购入生产货物甲的原材料一批,取得增值税专用发票上注明价款20000元,增值税3400元;购入生产货物乙的原材料一批,取得增值税专用发票上注明价
根据《证券法》的规定,某上市公司的下列事项中,不属于证券交易内幕信息的是()。
A注册会计师下列有关审计风险要素之间关系的表述中,恰当的是()。
关于初中综合实践活动主题的选择和设计,下列说法不正确的是()。
在我国,广义的刑法包括()。
人生观是人们对人生目的和人生意义的根本看法和态度,以下属于人生观范畴的有()
Readthefollowingtextandchoosethebestanswerfromtherightcolumntocompleteeachoftheunfinishedstatementsinthele
Whatjobdidthemangetfirst?Hegotthefirstjobas______.
最新回复
(
0
)