The calculation of 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的程序。
#include <stdio.h>
int main(){
int n;
double s;
double p;
double totalS;
double totalP;
while(scanf("%d",&n)!=EOF){
totalS=;
totalP=;
while(n--){
scanf("%lf%lf",&s,&p);
if(p==-)
continue;
totalS+=s;
if(p>=){
totalP+=s*;
}
else if(p>=){ //这里改成p>=80 && p<=89就不行了不知道为什么,好郁闷。。。
totalP+=s*;
}
else if(p>=){
totalP+=s*;
}
else if(p>=){
totalP+=s;
}
}
if(totalS==)
printf("-1\n");
else
printf("%.2lf\n",totalP/totalS);
}
return ;
}
The calculation of GPA的更多相关文章
- HDOJ 1202 The calculation of GPA
Problem Description 每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对于评奖学金是直接有关的.国外大学都是计算GPA(grade point average) 又称GPR(g ...
- 题解报告:hdu1202The calculation of GPA(算绩点问题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1202 Problem Description 每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对 ...
- hdu 1202 The calculation of GPA
感觉本题没有什么好解释的,已知公式,直接编程即可. 1.统计所有 科目的学分 得到总学分 2.统计所有 成绩对应的绩点*对应的学分即可(如果成绩==-1直接continue,不进行统计),得到总绩点. ...
- Problem : 1202 ( The calculation of GPA )
Losers always whine about their best. Winners go home and fuck the prom queen. 很操蛋却非常有意思的题目,注意变量的类型, ...
- OpenCASCADE Curve Length Calculation
OpenCASCADE Curve Length Calculation eryar@163.com Abstract. The natural parametric equations of a c ...
- 16090202(剑灵GPA)
[目标] 剑灵GPA [思路] 1 2 绘制角色DrawCall body 5526面片 2.1[第一个DrawCall]63 RT 这个DrawCall PS VS 参数列表 VS // // Ge ...
- hdu4965 Fast Matrix Calculation (矩阵快速幂 结合律
http://acm.hdu.edu.cn/showproblem.php?pid=4965 2014 Multi-University Training Contest 9 1006 Fast Ma ...
- inconsistent line count calculation in projection snapshot
1.现象 在vs2013中,按Ctrl + E + D格式化.cshtml代码,vs2013系统崩溃.报:inconsistent line count calculation in projecti ...
- 贪心 HDOJ 4726 Kia's Calculation
题目传送门 /* 这题交给队友做,做了一个多小时,全排列,RE数组越界,赛后发现读题读错了,囧! 贪心:先确定最高位的数字,然后用贪心的方法,越高位数字越大 注意:1. Both A and B wi ...
随机推荐
- mysql创建用户两次授权
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' -> IDENTIFIED BY 'some_pass' ...
- initialSize,maxTotal,maxIdle,minIdle,maxWaitMillis
初始化连接数:默认值 0 同一时刻可分配最大连接数:默认值 8 ,设置为负数时不做限制 最大空闲连接,默认值 8 ,超出连接将被释放 最小空闲连接数,默认值 0 请求连接最大等待时间(毫秒),默认值 ...
- My集合框架第二弹 二叉树的实现
package com.wpr.collection; import java.util.NoSuchElementException; public class BinarySearchTree&l ...
- Dubbo远程调用服务框架原理与示例
Dubbo 是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和 Spring框架无缝集成. 主要核心部件: Remoting: 网络通信框架 ...
- InitializingBean和init-method
[spring的InitializingBean的 afterPropertiesSet 方法 和 init-method配置的 区别联系] InitializingBean Spring的Initi ...
- PHP安装环境,服务器不支持curl_exec的解决办法
转自:http://jingyan.baidu.com/article/00a07f38909c6b82d028dc83.html windows下开启方法: 拷贝PHP目录中的libeay32.dl ...
- 10635 - Prince and Princess
Problem D Prince and Princess Input: Standard Input Output: Standard Output Time Limit: 3 Seconds In ...
- Swift学习资源
原文: http://leancodingnow.com/swift-learning-resources/ Swift是Apple在今年的WWDC推出的一门新的编程语言,它的1.0版本跟着Xcode ...
- iOS10适配知识点
http://ios.jobbole.com/89551/ http://ios.jobbole.com/88982/ 2.隐私数据访问问题 问题出现 现在app能运行了,当我打开相机时突然又cras ...
- 新建VM_Script
在Hyper-V群集中,不需要设置VM的自启动,当宿主机意外关机重新启动后,上面的VM会自动转移到另一台主机:如果另一台主机处于关机状态,则宿主机重新启动后,其VM也会自启动(如果其VM在宿主机关机前 ...