Sicily 1818. 成绩转换
来源:互联网 发布:信号屏蔽软件 编辑:程序博客网 时间:2024/05/31 00:39
Time Limit: 5 secs, Memory Limit: 32 MB
Description
保存学生姓名和成绩,然后通过姓名查询该学生的成绩等级。
输入为百分制的成绩,将其转换成对应的等级,具体转换规则如下:
90~100 为 A;
80~89 为 B;
70~79 为 C;
60~69 为 D;
0~59 为 E;
Input
输入有多组数据。第一行为数据组数T。
对于每组数据,第一行包含两个整数 n(1< n<=15000)和 m(1< m<=10000),n 表示学生个数,m 表示查询次数。接下来 n 行,每行包含一名学生的姓名和成绩。再接下来 m 行,每行一个字符串,表示学生姓名。
注意: 数据有可能有重复名字的学生,以最后一次出现的成绩为准。
Output
对于每个查询,输出一行, 表示该学生成绩等级。如果输入数据不在 0~100 范围内,请输出一行:“Score is error!”。
^_^ 五秒的时间给的很慷慨,使用STL中的map可以比较轻松的完成本题。**map在一对一数据元素进行匹配时具有的优势是其他结构所不具备的。**get?
#include <iostream>#include <string>#include <map>using namespace std;int main(){ int T; cin >> T; while (T--) { map<string, int> score; // 使用map申明Score结构 int NumOfInput, NumOfOutput; cin >> NumOfInput >> NumOfOutput; int num; string str; while (NumOfInput--) // 添加学生成绩 { cin >> str >> num; score[str] = num; } while (NumOfOutput--) // 输出 { cin >> str; if (score[str] >= 0) { if (score[str] <= 59) cout << "E" << endl; else if (score[str] <= 69) cout << "D" << endl; else if (score[str] <= 79) cout << "C" << endl; else if (score[str] <= 89) cout << "B" << endl; else if (score[str] <= 100) cout << "A" << endl; else cout << "Score is error!" << endl; } else cout << "Score is error!" << endl; } } return 0;}
0 0
- Sicily 1818. 成绩转换
- sicily--1818. 成绩转换
- sicily 1818.成绩转换
- Sicily 1818. 成绩转换
- Sicily 1818. 成绩转换
- Sicily 1818. 成绩转换
- sicily 1818 成绩转换
- 成绩转换
- 成绩转换
- 成绩转换
- 成绩转换
- 成绩转换
- 成绩转换
- 成绩转换
- 成绩转换
- 成绩转换
- 成绩转换
- 成绩转换
- C++, Java和C#的编译过程解析
- Lua封装延时执行函数
- 源码探索系列16---初篇结尾---那个被RecyclerView替代的Listview
- JS生成二维码(兼容各种浏览器及中文)
- RxJava练习(2)--时间间隔输出字符串
- Sicily 1818. 成绩转换
- Swift print 小技巧
- 安卓M-SettingsProvider新功能特性总结
- 类 对象 方法 属性
- 用SchemaExport生成数据库
- 如何科学的创建索引
- HttpGet登陆
- 2. AllowOverride以及Options使用详解
- synchronized的原子性以及DCL为什么出错的