#include<iostream>
#include<string>
using namespace std;
class Stu
{
public:
void setStudent(string na,int c,int m);
void show();
void setName(string na);
string getName();
float average();
private:
string name; //学生姓名
float chinese; //语文成绩
float math; //数学成绩
float ave;
float sum;
};
void Stu::setName(string na)
{
name=na;
}
void Stu::setStudent(string na,int c,int m)
{
name=na;
chinese=c;
math=m;
sum=math+chinese;
ave=sum/2;
}
void Stu::show()
{
cout<<"Name: "<<name<<endl;
cout<<"Score: "<<chinese<<" "<<math<<endl;
cout<<"average: "<<ave<<" Sum: "<<sum<<endl;
cout<<endl;
}
string Stu::getName()
{
return name;
}
C++第二次实验 学生成绩
最新推荐文章于 2023-12-29 20:58:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)