原题:

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. 《A_Pancers团队》作业5—团队项目需求改进与系统设计

    一:团队项目需求改进 1. <音乐播放软件需求规格说明书>的不足 在上周的<音乐播放软件需求规格说明书>我们还需要改进的地方有:1.搜索功能:2.界面的简洁美观化:3.按键的重 ...

  2. 远程SqlServer服务器

    ①,安装net framework3.5. ②,安装sqlserver2014(例). ③,基本配置. 安装sqlserver2014时,开启混合认证模式.当然,也可以在安装后,通过sqlserver ...

  3. oracle创建/删除表空间、创建/删除用户并赋予权限

    创建表空间 分开执行如下sql语句 --创建临时表空间 CREATE SMALLFILE TEMPORARY TABLESPACE "TEMP11" TEMPFILE 'E:\ap ...

  4. English trip -- VC(情景课)9 D Reading 阅读练习

    Read 阅读 Dear Susie(苏西) It's after dinner, My family is working in the kitchen. My daughter Li is  wa ...

  5. Confluence 6 快捷键

    快捷键图标. 官方的下载地址为:https://atlassianblog.wpengine.com/wp-content/uploads/2018/01/keyboard-shortcuts-inf ...

  6. 『Scrapy』爬虫框架入门

    框架结构 引擎:处于中央位置协调工作的模块 spiders:生成需求url直接处理响应的单元 调度器:生成url队列(包括去重等) 下载器:直接和互联网打交道的单元 管道:持久化存储的单元 框架安装 ...

  7. Python基础--列表、元组

    一.什么是列表.元组 序列是Python中最基本的数据结构.序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推. Python有6个序列的内置类型,但最常见 ...

  8. python-day10--字符编码

    1.回顾: 软件→操作系统→硬件 2.文本编辑器: 启动:硬盘→内存→运行(cpu) 读文件:硬盘→内存→CPU读 存文件:保存到硬盘中 3.python解释器 启动:硬盘→内存→运行(cpu) 读文 ...

  9. JSP EL简介

    JSP EL简介:1.语法:    ${expression} 2.[ ]与.运算符    EL 提供“.“和“[ ]“两种运算符来存取数据.     当要存取的属性名称中包含一些特殊字符,如.或?等 ...

  10. sql server中的大数据的批量操作(批量插入,批量删除)

    首先我们建立一个测试用员工表 ---创建一个测试的员工表--- create table Employee( EmployeeNo int primary key, --员工编号 EmployeeNa ...