HDU 4802
来源:互联网 发布:罂粟壳在淘宝上叫什么 编辑:程序博客网 时间:2024/06/01 11:18
GPA
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1861 Accepted Submission(s): 1121
Problem Description
In college, a student may take several courses. for each course i, he earns a certain credit (ci), and a mark ranging from A to F, which is comparable to a score (si), 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”.
Input
There are several test cases, please process till EOF.
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.
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.
Output
For each test case, print the GPA (rounded to two decimal places) as the answer.
Sample Input
52 B3 D-2 P1 F3 A22 P2 N64 A3 A3 A4 A3 A3 A
Sample Output
2.330.004.00
Hint
For the first test case:GPA =(3.0 * 2 + 1.0 * 3 + 0.0 * 1 + 4.0 * 3)/(2 + 3 + 1 + 3) = 2.33For the second test case: because credit in GPA computation is 0(P/N in additional treatment), so his/her GPA is “0.00”
一遍过的。。简单题,。
#include <stdio.h>#include <string.h>int main(){ int n;while(scanf("%d",&n)!=EOF){double a[1005];char b[3005][10];int i;memset(a,0,sizeof(a));for(i=1;i<=n;i++)scanf("%lf%s",&a[i],b[i]);double sum=0;double sum1=0;for(i=1;i<=n;i++){if(strcmp(b[i],"A")==0){sum+=a[i]*4.0;sum1+=a[i];}if(strcmp(b[i],"A-")==0){sum+=a[i]*3.7;sum1+=a[i];}if(strcmp(b[i],"B+")==0){sum+=a[i]*3.3;sum1+=a[i];}if(strcmp(b[i],"B")==0){sum+=a[i]*3.0;sum1+=a[i];}if(strcmp(b[i],"B-")==0){sum+=a[i]*2.7;sum1+=a[i];}if(strcmp(b[i],"C+")==0){sum+=a[i]*2.3;sum1+=a[i];}if(strcmp(b[i],"C")==0){sum+=a[i]*2.0;sum1+=a[i];}if(strcmp(b[i],"C-")==0){sum+=a[i]*1.7;sum1+=a[i];}if(strcmp(b[i],"D")==0){sum+=a[i]*1.3;sum1+=a[i];}if(strcmp(b[i],"D-")==0){sum+=a[i]*1.0;sum1+=a[i];}if(strcmp(b[i],"F")==0){sum+=0;sum1+=a[i];}}if(sum1)printf("%.2lf\n",sum/sum1);elseprintf("0.00\n"); }return 0;}
怒贴。。
0 0
- HDU 4802
- HDU 4802
- Hdu 4802 Hdu 4803 Hdu 4810 Hdu 4811
- HDU 4802 GPA
- hdu 4802 GPA(水题)
- HDU-#4802 GPA
- HDU - 4802 GPA
- HDU-4802-GPA
- hdu 4802 GPA
- hdu 4802 GPA
- GPA HDU 4802
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- 网页带参数下载(不管 参数编码,长度)
- ios 模拟器沙盒的位置
- vxWorks多任务编程初探-上
- 剑指offer 面试题29 寻找数组中出现次数超一半的数字
- Oracle 触发器中使用游标
- HDU 4802
- Xml配置View的点击事件
- Yii createCommand CURD操作
- C++11 FAQ中文版:std::function 和 std::bind
- 分享一个链接
- iOS开发之AVAudioPlayer 音频播放
- three.js 源码注释(四十八)Material /MeshBasicMaterial.js
- spring struts2 整合 action 注入service 报错NullPointerException
- Github-iOS备忘