杭电acm1004
来源:互联网 发布:关于淘宝规则的变更 编辑:程序博客网 时间:2024/04/28 15:40
自己写了代码,但是总是时间受限,所以在网上寻求帮助,下面是从网上看到了不错的代码:
#include <map>
#include <iostream>#include <string>
using namespace std;
int main()
{
int n;
string str;
map<string,int> strMap;
while(cin>>n && n)
{
strMap.clear();
for(int i = 0; i < n; ++ i)
{
cin>>str;
int t = strMap[str];
if(t)
{
strMap[str] ++;
}
else
{
strMap[str] = 1;
}
}
int nTemp;
string strTemp;
map<string,int>::const_iterator it = strMap.begin();
nTemp = it->second;
strTemp=it->first;
while(it != strMap.end())
{
if(it->second > nTemp)
{
nTemp = it->second;
strTemp = it ->first;
}
it ++;
}
cout<<strTemp<<endl;
}
return 0;
}
0 0
- 杭电ACM1004
- 杭电acm1004
- 杭电ACM1004
- 杭电ACM1004
- 杭电ACM1004
- 杭电acm1004
- 杭电ACM1004 数目最多的颜色
- 二维数组保存字符串应用(杭电acm1004)
- acm1004
- acm1004
- nupt-acm1004
- HDU--ACM1004
- 杭电
- 杭电
- 杭电
- acm1004 Let the B…
- 杭电 1234 和 杭电 2115
- 杭电2056之Rectangles 杭电
- ios 工程中ARC与MRC
- [ural1057]Amount of Degrees && 数位DP
- display:none; display:block; display:inline和display:inline-block;
- oracle 11g backupgroud process and archtecture
- $(document).ready()、 $(function(){})、$().ready(function(){})和window.onload的区别
- 杭电acm1004
- [ExecuteInEditMode] 和 [RequireComponent(typeof(UIRoot))]理解
- JavaScript导出到word、excel !!!
- 黑马程序员——Java基础---面向对象(封装、构造函数、this关键字)--第5天--第67-73集
- 刚刚接手的一个项目要用oracle数据库。把一些SQL SERVER2005的表导入过去以后发现查询时有问题,比如登陆时的查询
- C++复习题
- poj 1562(Deposits)水题(八连通)
- POJ1061 青蛙的约会 扩展欧几里得
- webx小结