poj 2153 Rank List(查找,Map)
题目链接:http://poj.org/problem?id=2153
思路分析:
判断Li Ming的成绩排名,需要在所有的数据章查找成绩比其高的人的数目,为查找问题。
查找问题可以使用Hash表,STL中的Map,查找树,或者使用排序与二分查找即可。
代码:
#include <iostream>
#include <map>
#include <string>
using namespace std; int main()
{
int personNum, examTimes, scoreOfLi;
string stuName;
map<string, int> rankList; cin >> personNum;
cin.get( );
for (int i = ; i < personNum; ++i)
{
getline(cin, stuName);
rankList[stuName] = ;
}
cin >> examTimes;
cin.get( );
for (int i = ; i < examTimes; ++ i)
{
int score; for (int j = ; j < personNum; ++ j)
{
cin >> score;
cin.get( );
getline(cin, stuName);
rankList[stuName] += score;
if (stuName == string("Li Ming"))
scoreOfLi = rankList[stuName];
} int rankOfLiMing = ;
for (map<string, int>::iterator iter = rankList.begin( ); iter != rankList.end(); ++iter)
{
if (iter->second > scoreOfLi)
rankOfLiMing++;
}
cout << rankOfLiMing << endl;
} return ;
}
poj 2153 Rank List(查找,Map)的更多相关文章
- POJ 2153 Rank List (map映射)
水题,竟然花了那么多时间...主要是不知道为什么,明明在本机上编译过去了,但是用c++提交却编译错误...最后用g++提交AC 题意:给出n个学生的名字,然后给出m个测验. 每个测验给出n个学生的分数 ...
- poj 2153 Rank List
原题链接:http://poj.org/problem?id=2153 简单题,map,平衡树均可.. map: #include<algorithm> #include<iostr ...
- poj 2503 Babelfish (查找 map)
题目:http://poj.org/problem?id=2503 不知道为什么 poj 的 数据好像不是100000,跟周赛的不一样 2000MS的代码: #include <iostrea ...
- 成绩累加排名,poj(2153)
题目链接:http://poj.org/problem?id=2153 解题报告: 注意map中的string,因此要将char[]转换为string型. #include <iostream& ...
- POJ 3096 Surprising Strings(STL map string set vector)
题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...
- poj 3087 Shuffle'm Up ( map 模拟 )
题目:http://poj.org/problem?id=3087 题意:已知两堆牌s1和s2的初始状态, 其牌数均为c,按给定规则能将他们相互交叉组合成一堆牌s12,再将s12的最底下的c块牌归为s ...
- POJ 2503 单词映射(map)
Sample Input dog ogdaycat atcaypig igpayfroot ootfrayloops oopslay atcayittenkayoopslaySample Output ...
- poj 2452(RMQ+二分查找)
题目链接: http://poj.org/problem?id=2452 题意:在区间[1,n]上找到满足 a[i]<a[k]<a[j] (i<=k<=j) 的最大子区间 (j ...
- HDOJ1251(前缀匹配---分块查找&map应用)
分块查找算法 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm ...
随机推荐
- 关于group by的一段SQl语句——Oracle
select cc.fformulacode, cc.rangedate, dd.fpervalue from (select n1.fformulacode, max(n1.frangedate) ...
- C#委托的简单剖析
为什么在Button1的Click事件发生之后,button1_Click方法就会被调用呢? 实际上,在我们双击Button1的时候,IDE自动的添加了一段代码,该段代码位于“Form1.Design ...
- 数据持久化------Archiving(归档,解档)
其中TRPerson为自定义的继承自NSObject的类的子类 其中有两个属性,name 和 age .h文件 #import @interface TRPerson : NSObject<& ...
- 删除除了 id 号不同,其他都相同的学生冗余信息
删除除了 id 号不同,其他都相同的学生冗余信息2.学生表 如下:id 号 学号 姓名 课程编号 课程名称 分数1 2005001 张三 0001 数学 692 2005002 李四 0001 数学 ...
- hadoop搭建杂记:Linux下hostname的更改办法
VirtualBox搭建hadoop伪分布式模式:更改hostname VirtualBox搭建hadoop伪分布式模式:更改hostname master: ip:192.168.56.120 机器 ...
- js中this的四种使用方法
0x00:js中this的四种调用模式 1,方法调用模式 2,函数调用模式 3,构造器调用模式 4,apply.call.bind调用模式 0x01:第一种:方法调用模式 (也就是用.调用的)this ...
- 关于CSS动画几点要注意的地方
关于CSS动画几点要注意的地方 js操作transition无效果 先看这个demo以及stackoverflow的问题 http://jsfiddle.net/ThinkingStiff/QNnnQ ...
- Chrome设计文档-多进程架构
chromium multi-process architecture 本文档从high-level的角度描述Chromium的多进程架构. 问题 要构建一个决不崩溃或挂起的渲染引擎几乎是不可能的.同 ...
- 依赖注入(DI)和控制反转(IOC)
依赖注入(DI)和控制反转(IOC) 0X1 什么是依赖注入 依赖注入(Dependency Injection),是这样一个过程:某客户类只依赖于服务类的一个接口,而不依赖于具体服务类,所以客户类只 ...
- Core第三方开源Web框架
NET Core第三方开源Web框架YOYOFx YOYOFx框架 YOYOFx是一个轻量级用于构建基于 HTTP 的 Web 服务,基于 .NET 和 Mono 平台. 本着学习的态度,造了这个 ...