HDU 1202 The calculation of GPA
来源:互联网 发布:淘宝店铺装修插件 编辑:程序博客网 时间:2024/06/05 10:43
http://acm.hdu.edu.cn/showproblem.php?pid=1202
The calculation of GPA
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K(Java/Others)
Total Submission(s): 11025 Accepted Submission(s):2556
Problem Description
每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对于评奖学金是直接有关的。国外大学都是计算GPA(grade pointaverage) 又称GPR(grade pointratio),即成绩点数与学分的加权平均值来代表一个学生的成绩的。那么如何来计算GPA呢?
一般大学采用之计分法
A90 - 100 4 点
B80 - 89 3 点
C70 - 79 2 点
D60 - 69 1 点
E0 - 59 0 点
例如:某位学生修习三门课,其课目、学分及成绩分别为:
英文:三学分、92 分;化学:五学分、80 分;数学:二学分、60分,则GPA的算法如下:
科目 学分 分数 点数 分数×点数
英文 3 92 4 12
化学 5 80 3 15
数学 2 60 1 2
合计 10 29
29/10=2.9
2.9即为某生的GPA
下面有请你写一个用于计算GPA的程序。
一般大学采用之计分法
A90 - 100 4 点
B80 - 89 3 点
C70 - 79 2 点
D60 - 69 1 点
E0 - 59 0 点
例如:某位学生修习三门课,其课目、学分及成绩分别为:
英文:三学分、92 分;化学:五学分、80 分;数学:二学分、60分,则GPA的算法如下:
科目 学分 分数 点数 分数×点数
英文 3 92 4 12
化学 5 80 3 15
数学 2 60 1 2
合计 10 29
29/10=2.9
2.9即为某生的GPA
下面有请你写一个用于计算GPA的程序。
Input
包含多组数据,每组数据的第一行有一个数N,接下来N行每行表示一门成绩。每行有两个实型的数s,p,s表示这门课的学分,p表示该学生的成绩(百分制)。如果p=-1则说明该学生这门课缺考,是不应该计算在内的。
Output
对每组数据输出一行,表示该学生的GPA,保留两位小数。如果GPA不存在,输出-1。
Sample Input
3 3 92 5 802 60
Sample Output
2.90
Author
Speakless
Source
Gardon-DYGG Contest 2
Recommend
JGShining
分析:简单题。。
代码如下:
#include<stdio.h>
int main()
{
int T;
double s,p,sum,t;
double sum_s,sum_p;
while(scanf("%d",&T)==1)
{
sum_s=sum_p=0;
while(T--)
{
scanf("%lf%lf",&s,&p);
t=s;
if(p>=0)
{
if(p>=90)
sum_p+=(s*=4);
elseif(p>=80)
sum_p+=(s*=3);
elseif(p>=70)
sum_p+=(s*=2);
elseif(p>=60)
sum_p+=s;
else
continue;
sum_s+=t;
//printf("sum_s=%lfsum_p=%lf\n",sum_s,sum_p);
}
}
//printf("sum_s=%lfsum_p=%lf\n",sum_s,sum_p);
if(sum_s!=0)
printf("%.2lf\n",sum_p/sum_s);
else
printf("-1\n");
}
return 0;
}
int main()
{
}
阅读全文
0 0
- HDU 1202 The calculation of GPA
- HDU 1010 Tempter of the Bone
- hdu 1692 Destroy the Well of Lif…
- HDOJ 1010 Tempter of the Bone
- HDU 1405 The Last Practice
- The Sound of Silence
-  
- failure of the “Grid Installatio…
- HDU 2088 Box of Bricks
- HDU 1326 Box of Bricks
- HDU 1355 The Peanuts
- hdu 1081 To The Max
- HDU 2137 circumgyrate the string
- HDU 1405 The Last Practice
-
- What are the meaning of the code…
- HDOJ 1709 The Balance
- To add a multiplexed copy of the…
- HDU 1279 验证角谷猜想
- Android Studio用release模式进行调试
- HDU 1248 寒冰王座
- HDU 1234 开门人和关门人
- HDU 1219 AC Me
- HDU 1202 The calculation of GPA
- mybatis generator工具类 自动生成 配置文件以及实体类
- HDU 1170 Balloon Comes!
- HDU 1164 Eddy's research I
- HDU 1157 Who's in the Middle
- 常用数据类型转换CString do…
- 关于C++ 除法丢失数据
- android上层如何默认开启ZSD
- USACO transform