谁得了最高奖学金
来源:互联网 发布:mongodb在java使用方法 编辑:程序博客网 时间:2024/04/20 08:43
结构体得运用
#include<iostream>#include<iterator>#include<set>using namespace std;struct student{char name[20];int Grade;int Gradeclass;char leader;char West;int Thesis;int Scholarship;};bool operator<(const student& s1,const student& s2){return s1.Scholarship>s2.Scholarship;}int Count(student &s){ s.Scholarship=0; if(s.Grade>80&&s.Thesis>=1) s.Scholarship+=8000; if(s.Grade>85&&s.Gradeclass>80) s.Scholarship+=4000; if(s.Grade>90) s.Scholarship+=2000; if(s.Grade>85&&s.West=='Y') s.Scholarship+=1000; if(s.Gradeclass>80&&s.leader=='Y') s.Scholarship+=850;return s.Scholarship;}int main(){int N;cin>>N;while(N--){int num;cin>>num;student s;set<student>group;int Total=0;for(int i=0;i<num;i++){cin>>s.name>>s.Grade>>s.Gradeclass>>s.leader>>s.West>>s.Thesis; Total+=Count(s); group.insert(s);}set<student>::iterator it=group.begin();cout<<it->name<<endl<<it->Scholarship<<endl<<Total<<endl;}}
在重载输入流得时候出了问题
//istream& operator>>(istream& in,student s)//{//in>>s.name>>s.Grade>>s.Gradeclass>>s.leader>>s.West>>s.Thesis;//return in;//}==! 没加引用。。丢人
#include<iostream>#include<iterator>#include<set>using namespace std;struct student{char name[20];int Grade;int Gradeclass;char leader;char West;int Thesis;int Scholarship;};istream& operator>>(istream& in,student &s){in>>s.name>>s.Grade>>s.Gradeclass>>s.leader>>s.West>>s.Thesis;return in;}bool operator<(const student& s1,const student& s2){return s1.Scholarship>s2.Scholarship;}int Count(student &s){ s.Scholarship=0; if(s.Grade>80&&s.Thesis>=1) s.Scholarship+=8000; if(s.Grade>85&&s.Gradeclass>80) s.Scholarship+=4000; if(s.Grade>90) s.Scholarship+=2000; if(s.Grade>85&&s.West=='Y') s.Scholarship+=1000; if(s.Gradeclass>80&&s.leader=='Y') s.Scholarship+=850;return s.Scholarship;}int main(){int N;cin>>N;while(N--){int num;cin>>num;set<student>group;int Total=0;for(int i=0;i<num;i++){ student s;cin>>s; Total+=Count(s); group.insert(s);}set<student>::iterator it=group.begin();cout<<it->name<<endl<<it->Scholarship<<endl<<Total<<endl;}}
0 0
- 谁得了最高奖学金
- NYOJ-60谁得了最高奖学金
- 谁获得最高奖学金
- 谁获得最高奖学金
- 谁获得最高奖学金
- 奖学金(谁获得了最高奖学金)
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- 谁获得了最高奖学金
- android实现静默安装和跳过卸载弹窗直接卸载应用
- 微信调整服务号规则,服务号每月群发4条
- 程序员的提升要素
- 一样降价出售,而是干脆地从苹果的产品线中去除掉
- 威胁建模学习笔记1
- 谁得了最高奖学金
- 'release' is unavailable: not available in automatic reference counting mode..
- JQuery优秀插件收集
- 默认使用JDK版本切换
- Cognos函数(一) - 时间函数
- java入门第三步之数据库连接
- 【数据库摘要】3_Sql_Select_Top
- Android学习 之 ColorStateList按钮文字变色
- 5-OMAPL138开发板Linux系统固化到NAND FLASH步骤