问题麻烦,希望大家耐心帮我解决 谢谢各位~~

来源:百度知道 编辑:UC知道 时间:2024/07/02 02:54:31
各位大侠麻烦帮我编下这个题目,我自己也已经编了,但是很多错误。所以想看看正确的。谢谢谢
编写一个类以及相关的函数,来为选这门课的学生生成学生成绩。假设成绩只于期中和期末成绩有关,是期中和期末成绩的平均。如果大于等于60则输出P,反之则输出F。在成绩报告中,按照字母表的顺序排列所有学生,并用PF表示成绩。
我的程序:int main()
{vector<int> student;
while(cin>>x)
student.pushback(x);
class student{
public: std::istream& cmp(std::istream& );
private: double mid,final;string name;}
istream& student::cmp()
{if((mid+final)/2>60)
cout<<"p"<<endl;
else cout<<f"<<endl;}
for(vector<student>::size_type i=0;i!=student.size();++i)
{cout<<student[i].name<<endl;
cmp(student[i].mid,student[i].final)
}字母显示还不会编~~谢谢啊

题目里面这句“在成绩报告中,按照字母表的顺序排列所有学生,并用PF表示成绩”很模糊,是要写一个程序还是就一个类。

我帮你写了个类

class student
{

public:
student();
student(student &s)
{
name = s.name;
mid = s.mid;
final = s.final;
};
student(string &n,double m,double f) : name(n),mid(m),final(f) {};
~student;
char GetScore()
{
if((mid+final)/2>60)
return 'P';
else return 'F';
}
;
private:
double mid,final;
string name;
}

至于main里面怎么输入,输出,题目也没讲清楚。用vector是对的,不过应该是这样定义

vector<stduent> stu_vec;