题目链接: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)的更多相关文章

  1. POJ 2153 Rank List (map映射)

    水题,竟然花了那么多时间...主要是不知道为什么,明明在本机上编译过去了,但是用c++提交却编译错误...最后用g++提交AC 题意:给出n个学生的名字,然后给出m个测验. 每个测验给出n个学生的分数 ...

  2. poj 2153 Rank List

    原题链接:http://poj.org/problem?id=2153 简单题,map,平衡树均可.. map: #include<algorithm> #include<iostr ...

  3. poj 2503 Babelfish (查找 map)

    题目:http://poj.org/problem?id=2503 不知道为什么 poj  的 数据好像不是100000,跟周赛的不一样 2000MS的代码: #include <iostrea ...

  4. 成绩累加排名,poj(2153)

    题目链接:http://poj.org/problem?id=2153 解题报告: 注意map中的string,因此要将char[]转换为string型. #include <iostream& ...

  5. POJ 3096 Surprising Strings(STL map string set vector)

    题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...

  6. poj 3087 Shuffle'm Up ( map 模拟 )

    题目:http://poj.org/problem?id=3087 题意:已知两堆牌s1和s2的初始状态, 其牌数均为c,按给定规则能将他们相互交叉组合成一堆牌s12,再将s12的最底下的c块牌归为s ...

  7. POJ 2503 单词映射(map)

    Sample Input dog ogdaycat atcaypig igpayfroot ootfrayloops oopslay atcayittenkayoopslaySample Output ...

  8. poj 2452(RMQ+二分查找)

    题目链接: http://poj.org/problem?id=2452 题意:在区间[1,n]上找到满足 a[i]<a[k]<a[j] (i<=k<=j) 的最大子区间 (j ...

  9. HDOJ1251(前缀匹配---分块查找&map应用)

    分块查找算法 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm ...

随机推荐

  1. C++学习之运算符重载的总结

    C++学习之运算符重载的总结              运算符重载是对已有的运算符赋予多重含义,使同一个运算符作用域不同类型的数据导致不同行为的发生,C++为运算符重载提供了一种方法,即运算符重载函数 ...

  2. Oracle经典书籍推荐

    转自:http://www.cnblogs.com/fjfzhkb/archive/2007/12/05/983381.html 很多网友询问如何选择入门书籍,学Oracle有什么好书,这里给出一些常 ...

  3. python 常用模块及方法

    ******************** PY核心模块方法 ******************** os模块: os.remove()         删除文件 os.unlink()        ...

  4. MD5 加密 以及 加盐加密

    这是MD5加密 - (NSString *)MD5Hash { const char *cStr = [self UTF8String]; unsigned char result[16]; CC_M ...

  5. [转]printf 函数实现的深入剖析

    研究printf的实现,首先来看看printf函数的函数体 int printf(const char *fmt, ...) { int i; char buf[256];          va_l ...

  6. HortonWorks

    http://zh.hortonworks.com/products/hortonworks-sandbox/

  7. RTTI、虚函数和虚基类的实现方式、开销分析及使用指导(虚函数的开销很小,就2次操作而已)

    白杨 http://baiy.cn “在正确的场合使用恰当的特性” 对称职的C++程序员来说是一个基本标准.想要做到这点,首先要了解语言中每个特性的实现方式及其开销.本文主要讨论相对于传统 C 而言, ...

  8. Qt实现嵌入桌面的半透明窗口 good

    这儿用上了前面一文提到的函数findDesktopIconWnd().见: http://mypyg.blog.51cto.com/820446/263349 一.将Qt窗口嵌入到桌面中.声明一个最简 ...

  9. 一步一步学习SignalR进行实时通信_2_Persistent Connections

    原文:一步一步学习SignalR进行实时通信_2_Persistent Connections 一步一步学习SignalR进行实时通信\_2_Persistent Connections Signal ...

  10. [转]maven入门

    http://wentao365.iteye.com/blog/903396 Maven是一个采用纯Java编写的开 源项目管理工具.Maven采用了一种被称之为project object mode ...