标题:谁来给改一下程序,不胜感激
取消只看楼主
豪饮孤独
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-5-28
 问题点数:0 回复次数:0 
谁来给改一下程序,不胜感激

设计一个学生类(CStudent),它具有的私有数据成员是:注册号、姓名、数学、外语、计算机课程的成绩。定义一个学生数组,并输入每个学生的信息,然后在数组中搜索注册号为n的学生号,并返回该生的全部信息。

麻烦谁给改一下
不胜感激
最好弄成数组式的


private:
int id;
string name;
double maths;
double foreign_language;
double computer;
};

ostream& operator<<(ostream& out, const CStudent &rhs)
{
out<<rhs.id<<"\t"<<rhs.name<<"\t"<<rhs.maths<<"\t"<<rhs.foreign_language<<"\t"<<rhs.computer;
return out;
}

int main()
{
int Id;
string Name;
double Maths,Foreign_language,Computer;

map<int,CStudent> grade_list;
cout<<"输入学生信息:\n";
while(cin>>Id>>Name>>Maths>>Foreign_language>>Computer)
{
CStudent stu(Id,Name,Maths,Foreign_language,Computer);
grade_list.insert(make_pair(stu.get_id(),stu));
}
cin.clear();
string tmp;
cin>>tmp;
int search;
cout<<"要查找的学号:";
cin>>search;
cout<<grade_list.find(search)->second;
return 0;
}

搜索更多相关主题的帖子: 感激 
2006-05-28 14:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-67974-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.800517 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved