map容器的初体验
来源:互联网 发布:端口定义 编辑:程序博客网 时间:2024/06/05 12:07
In college, a student may take several courses. for each course i, he earns a certain credit (c i), and a mark ranging from A to F, which is comparable to a score (s i), according to the following conversion table
The GPA is the weighted average score of all courses one student may take, if we treat the credit as the weight. In other words,
An additional treatment is taken for special cases. Some courses are based on “Pass/Not pass” policy, where stude nts earn a mark “P” for “Pass” and a mark “N” for “Not pass”. Such courses are not supposed to be considered in computation. These special courses must be ignored for computing the correct GPA.
Specially, if a student’s credit in GPA computation is 0, his/her GPA will be “0.00”.
The GPA is the weighted average score of all courses one student may take, if we treat the credit as the weight. In other words,
An additional treatment is taken for special cases. Some courses are based on “Pass/Not pass” policy, where stude nts earn a mark “P” for “Pass” and a mark “N” for “Not pass”. Such courses are not supposed to be considered in computation. These special courses must be ignored for computing the correct GPA.
Specially, if a student’s credit in GPA computation is 0, his/her GPA will be “0.00”.
Each test case starts with a line containing one integer N (1 <= N <= 1000), the number of courses. Then follows N lines, each consisting the credit and the mark of one course. Credit is a positive integer and less than 10.
52 B3 D-2 P1 F3 A22 P2 N64 A3 A3 A4 A3 A3 A
2.330.004.00
#include <iostream>#include <cstdio>#include <map>#include <string>using namespace std;int main(){ map <string,double> mp; int n; mp["A"]=4.0; mp["A-"]=3.7; mp["B+"]=3.3; mp["B"]=3.0; mp["B-"]=2.7; mp["C+"]=2.3; mp["C"]=2.0; mp["C-"]=1.7; mp["D"]=1.3; mp["D-"]=1.0; mp["F"]=0; mp["P"]=0; mp["N"]=0; while(~scanf("%d",&n)) { double score=0.0; double all=0.0; string s; double a; for(int i=1;i<=n;i++) { cin>>a>>s; if(s=="P"||s=="N") continue; else {score+=a; all+=a*mp[s];} } //printf("%lf %lf\n",score,all); if(score!=0.0&&all!=0.0) printf("%.2lf\n",all/score); else cout<<"0.00"<<endl; } return 0;}
0 0
- map容器的初体验
- std::map初体验
- map容器的使用
- map容器的使用
- 容器Map的遍历
- MAP容器的使用
- map容器的用法
- map容器的使用
- 容器map的使用
- Map容器的使用
- c++的map容器
- Map容器的使用
- map容器的遍历
- 对于容器map的使用---map::value_type
- Map容器的用法(STL)
- Map容器的用法(STL)
- Java容器map的用法
- map容器的c实现
- Java内存分配续
- self parent this 区别
- erlang 四大 behaviour【转】
- Unity3d实现人物跳跃
- Rmarkdown中文实现
- map容器的初体验
- Python爬虫(2)——爬取微博内容
- 《重构-改善既有代码的设计》读后感
- 配置Log4j(很详细)
- nyoj-街区最短路径问题
- Glide源码分析
- HMLT/CSS
- HDU4283 区间dp
- 待解决