原题:

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
B F F C C A
D C E F
 
Sample Output
2.00
1.83
Unknown letter grade in input
 
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的更多相关文章

  1. 16090202(剑灵GPA)

    [目标] 剑灵GPA [思路] 1 2 绘制角色DrawCall body 5526面片 2.1[第一个DrawCall]63 RT 这个DrawCall PS VS 参数列表 VS // // Ge ...

  2. 使用 Intel GPA 与 分析3D程序和抓取模型

    原文链接在这里 http://dev.cra0kalo.com/?p=213 背景信息 Intel的GPA本身是一款图形分析软件,并没有设计从3D程序里抓取模型资源的功能,但这里作者是通过hook G ...

  3. 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) ...

  4. The calculation of GPA

    Problem Description 每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对于评奖学金是直接有关的.国外大学都是计算GPA(grade point average) 又称GPR(g ...

  5. HDU 4968 Improving the GPA

    Improving the GPA Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  6. HDOJ 1202 The calculation of GPA

    Problem Description 每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对于评奖学金是直接有关的.国外大学都是计算GPA(grade point average) 又称GPR(g ...

  7. 使用GPA针对android应用的绘制分析

    使用GPA针对android应用的绘制分析 以前经常用GPA来perf端游的绘制,很多perf工具例如perfhud,pix对于加壳的程序总是束手无策,但是GPA却不受这个限制,可以自动HOOK 3D ...

  8. GPA简介

    GPA(Graphics Performance Analyzers)是Intel公司提供的一款免费的跨平台性能分析工具. 填写e-mail.name和country并提交后,就会收到一封有专属下载链 ...

  9. hdu 4968 最大最小gpa

    http://acm.hdu.edu.cn/showproblem.php?pid=4968 给定平均分和科目数量,要求保证及格的前提下,求平均绩点的最大值和最小值. dp[i][j]表示i个科目,总 ...

  10. Improving the GPA(hdu4968)dfs

    Improving the GPA Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...

随机推荐

  1. [ios]NSThread传值 NSValue传值

    NSThread:http://www.cocoachina.com/bbs/read.php?tid=51873 NSValue:http://blog.sina.com.cn/s/blog_bf9 ...

  2. Linux环境下 RabbitMQ 的下载与安装

    0 环境 CentOS7 RabbitMQ 3.6.5 erlang 18.3 socat rabbitmq是使用erlang语言编写的,所以需要先安装erlang,其次rabbitmq安装依赖于so ...

  3. 算法笔记--2-sat

    强连通分量的应用,详见<挑战程序设计>P324 例题1:HDU Peaceful Commission 思路:强连通分量分解,看有没有两个同一个国家的代表在一个强连通分量里,如果有,就是N ...

  4. mac 下安装mongodb

    转载自https://segmentfault.com/a/1190000002547229 概念 MongoDB 是一个跨平台的,面向文档的数据库,提供高性能,高可用性和可扩展性方便. MongoD ...

  5. oracle 临时表的使用

    在oracle中,临时表分为会话级别(session)和事务级别(transaction)两种. 会话级的临时表在整个会话期间都存在,直到会话结束:事务级别的临时表数据在transaction结束后消 ...

  6. TortoiseXX 与TotalCommander (TC)的图标问题

    TortoiseXX通过overlay图标标志文件或文件夹是否被修改等状态,非常有用. 可惜TotoalCommander上,这些图标都没有显示. 其实,只需要在TC的菜单 配置->显示-> ...

  7. English trip -- VC(情景课) 7 A Shopping 购物

    Words The clothes place a dress 长裙      short skirt 短裙 pants 裤子   /  trousers 长裤  / shorts 短裤 a shir ...

  8. hdoj4283 You Are the One

    题意:每个人出场时获得等待时间*值的unhappy值.有个栈换出场顺序.问怎样最小? 一开始的时候觉得在中间取断点,dp[i][j]表示区间全出场后的最小值.那么dp[i][j]=dp[i][k]+d ...

  9. shell中引号的妙用

    #!/bin/bashfile=('leon 01.cap' leon-02.cap nicky-01.cap whoareu-01.cap 8dbb-01.cap)dict=(simple.txt ...

  10. hdu6394Tree lct

    树上弹飞绵羊,现场树分块没写出来= = 先预处理倍增,新建一个n+1节点,能弹到就建一条边,然后每操作2就cut,然后link,1的答案就是x到n+1的距离, //#pragma GCC optimi ...