GPA
原题:
GPA |
| Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) |
| Total Submission(s): 3645 Accepted Submission(s): 1489 |
|
Problem Description
Each course grade is one of the following five letters: A, B, C, D, and F. (Note that there is no grade E.) The grade A indicates superior achievement , whereas F stands for failure. In order to calculate the GPA, the letter grades A, B, C, D, and F are assigned the following grade points, respectively: 4, 3, 2, 1, and 0.
|
|
Input
The input file will contain data for one or more test cases, one test case per line. On each line there will be one or more upper case letters, separated by blank spaces.
|
|
Output
Each line of input will result in exactly one line of output. If all upper case letters on a particular line of input came from the set {A, B, C, D, F} then the output will consist of the GPA, displayed with a precision of two decimal places. Otherwise, the message "Unknown letter grade in input" will be printed.
|
|
Sample Input
A B C D F |
|
Sample Output
2.00 |
|
Author
2006Rocky Mountain Warmup
|
|
Source
HDU “Valentines Day” Open Programming Contest 2009-02-14
|
|
Recommend
lcy
|
源代码:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std; int main() {
double result;
string bbb;
int sum = , count = ;
char aaa;
while (getline(cin, bbb)) {
bool judge = true;
for (int i = ; i < bbb.length(); i++) {
aaa = bbb[i];
switch (aaa) {
case 'A':{
sum += ;
count++;
break;
}
case 'B':{
sum += ;
count++;
break;
}
case 'C':{
sum += ;
count++;
break;
}
case 'D':{
sum += ;
count++;
break;
}
case 'F':{
count++;
break;
}
case ' ':{
break;
}
default:{
judge = false;
break;
}
}
}
result = sum * 1.0 / count; // sum, count都是int型,一定记住在两个int型要转换成double型时,要乘1.0
if (judge) cout << fixed << setprecision() << result << endl; // setpresicion的单词要拼写对
else cout << "Unknown letter grade in input" << endl;
sum = ; count = ; //记得初始化为0
}
return ;
}
GPA的更多相关文章
- 16090202(剑灵GPA)
[目标] 剑灵GPA [思路] 1 2 绘制角色DrawCall body 5526面片 2.1[第一个DrawCall]63 RT 这个DrawCall PS VS 参数列表 VS // // Ge ...
- 使用 Intel GPA 与 分析3D程序和抓取模型
原文链接在这里 http://dev.cra0kalo.com/?p=213 背景信息 Intel的GPA本身是一款图形分析软件,并没有设计从3D程序里抓取模型资源的功能,但这里作者是通过hook G ...
- Improving the GPA 分类: 贪心 HDU 比赛 2015-08-08 16:12 11人阅读 评论(0) 收藏
Improving the GPA Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- The calculation of GPA
Problem Description 每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对于评奖学金是直接有关的.国外大学都是计算GPA(grade point average) 又称GPR(g ...
- HDU 4968 Improving the GPA
Improving the GPA Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Othe ...
- HDOJ 1202 The calculation of GPA
Problem Description 每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对于评奖学金是直接有关的.国外大学都是计算GPA(grade point average) 又称GPR(g ...
- 使用GPA针对android应用的绘制分析
使用GPA针对android应用的绘制分析 以前经常用GPA来perf端游的绘制,很多perf工具例如perfhud,pix对于加壳的程序总是束手无策,但是GPA却不受这个限制,可以自动HOOK 3D ...
- GPA简介
GPA(Graphics Performance Analyzers)是Intel公司提供的一款免费的跨平台性能分析工具. 填写e-mail.name和country并提交后,就会收到一封有专属下载链 ...
- hdu 4968 最大最小gpa
http://acm.hdu.edu.cn/showproblem.php?pid=4968 给定平均分和科目数量,要求保证及格的前提下,求平均绩点的最大值和最小值. dp[i][j]表示i个科目,总 ...
- Improving the GPA(hdu4968)dfs
Improving the GPA Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
随机推荐
- Qt5_pro_01
1. QT += core gui \ sql \ #ZC: 这个对应 #include <SQL/???> (如<QtSql/QSqlDatabase><QtSql/Q ...
- android 开发 出错
Error:Execution failed for task ':app:processDebugResources'. > com.android.ide.common.process.Pr ...
- 一个十分好用的动画工具:Velocity.js
就像许多开发者确信的那样,在Web上使用CSS实现动画并不是唯一的方式,我们也可以使用JS来实现,并且JS还有一些CSS无法替代的优势. 然而抛开JS而选择CSS来实现动画,将以样式表内容膨胀,丧失对 ...
- 【Python】给图片添加水印的Python及Golang实现
前言 不知道大家有没有这样的习惯,一篇比较得意的博客在发表一段时间之后会特别关注,前段时间一篇写到凌晨的博客被 码迷 这个网关爬取之后发表了,因为搜索引擎先爬取码迷的,所以我的博客无法被搜索到,即使直 ...
- putty xming gnome-session
在windows里远程连接linux的最好方法. 比VNC方式好多了 1) xming启动一个窗口 2) putty 设置完X11 forwarding之后,远程登录 3) 在putty 里启动 gn ...
- English trip V1 - 7.My dream car 我梦想的车 Teacher:Lamb Key: famous for
中华In this lesson you will learn to describe an object(目标). 课上内容(Lesson) famous for 以…著称,闻名 国家(名词) ...
- 4-6 select_tag和select的区别和理解。javascript_tag
via: :all是什么意思?主要用于约束http动作. <%= select_tag "set_locale", options_for_select(LANGUAGES, ...
- android--------热修复介绍
热修复技术在近年来飞速发展,尤其是在InstantRun方案推出之后,各种热修复技术竞相涌现.国内大部分成熟的主流APP都拥有自己的热修复技术,像手淘.支付宝.QQ.饿了么.美团等等. 代码热修复是最 ...
- Android 列表使用(ListView GridView Gallery图片计时滚动)
ListView 作用: 1.将数据填充到布局. 2.处理用户的选择点击等操作. 根据列表的适配器类型,列表分为三种,ArrayAdapter,SimpleAdapter和SimpleCursorAd ...
- CodeForces 558B
Description Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make ...