原题:

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. new JSONObject(str)无法解析 报错:org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject

    org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject 解析服务器返回的Jso ...

  2. 雷林鹏分享:Ruby 循环

    Ruby 循环 Ruby 中的循环用于执行相同的代码块若干次.本章节将详细介绍 Ruby 支持的所有循环语句. Ruby while 语句 语法 while conditional [do] code ...

  3. LeetCode--203--删除链表中的节点

    问题描述: 删除链表中等于给定值 val 的所有节点. 示例: 输入: 1->2->6->3->4->5->6, val = 6 输出: 1->2->3 ...

  4. Jersey 2.x 基于 Servlet 的服务器端应用

    下面的依赖通常应用到应用服务器上(servlet 容器),同时这个应用服务器上没有整合任何 JAX-RS 的实现. 因此,这个应用服务器需要包含有 JAX-RS API 和 Jersey 实现,同时部 ...

  5. 为tomcat指定jdk

    安装好jdk,不配置环境变量 windows平台 在catalina.bat文件和setclasspath.bat文件开头的空白处加上如下两句(指定JDK): \jre linux平台 在catali ...

  6. Vue自动化工具(Vue-CLI)

    一.组件的概念 1.概念 组件(Component)是自定义封装的功能.在前端开发过程中,经常出现多个网页的功能是重复的,而且很多不同的网站之间,也存在同样的功能. 而在网页中实现一个功能,需要使用h ...

  7. Python_Cxfreeze打包exe

    Cxfreeze打包exe   1● 下载cxfreeze 1◆   python -m pip install cx_Freeze --upgrade     https://sourceforge ...

  8. learning uboot auto switch to stanbdy system in qca4531 cpu

    design: when uboot load kerne failed,we can switch to stanbdy system; how to realize: when boot fail ...

  9. learning armbian steps(2) ----- armbian 镜像编译

    参考:https://docs.armbian.com/Developer-Guide_Build-Preparation/ 通过如下指令进行编译: apt-get -y -qq install gi ...

  10. js运动例子1

    <!doctype html> <html> <head> <meta charset="utf-8"> <meta name ...