C++教材练习题参考答案(16)

2020-11-29 00:50

中国铁道建设出版

void print (score st[], int n)

{

cout<<"No. "<<" 姓名 "<<" 平均 "<<" C++ "<<" 英语 "<<" 数学 "<<endl ;

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

{

cout<<st[i].no ;

cout<<'\t'<<st[i].name ;

cout<<'\t'<<st[i].average ;

cout<<'\t'<<st[i].c ;

cout<<'\t'<<st[i].english ;

cout<<'\t'<<st[i].maths<<endl ;

}

}

3.[程序如下]

#include <iostream.h>

struct student

{

long int num;

float CPPmid;

float CPPend;

float ave;

};

void main()

{student s[3];

student *p;

for(p=s;p<s+3;p++)

{

cout<<"请输入学生学号:" ; cin>>p->num;

cout<<"请输入C++期中成绩:" ; cin>>p->CPPmid;

cout<<"请输入C++期末成绩:" ; cin>>p->CPPend;

p->ave=(p->CPPmid+p->CPPend)/2;

}

cout<<"No. "<<" 平均 "<<" C++期中 "<<" C++期末 "<<endl ;

for(p=s;p<s+3;p++)

{

cout<<p->num ;

cout<<'\t'<<p->ave;

cout<<'\t'<<p->CPPmid ;

cout<<'\t'<<p->CPPend;

cout<<endl;

}

}


C++教材练习题参考答案(16).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:快乐的鱼创业故事7

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: