中国铁道建设出版
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;
}
}