您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> C/C++ >> 航电1004题

航电1004题

来源:网络整理     时间:2016/8/27 6:45:40     关键词:

关于网友提出的“ 航电1004题”问题疑问,本网通过在网上对“ 航电1004题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 航电1004题
描述:

http://acm.hdu.edu.cn/showproblem.php?pid=1004
这是我的代码,总是不能通过,可是我觉得我的格式和答案都没有错啊。

#include 
#include 
#include 
using namespace std;
string foo(int n)
{
map color_count;
string color;
string s;
for(int i = 0 ;i < n ;++i)
{
cin >> color ;
//在map中查找color,找到则将他出现的次数家一,没有找到则插入他,出现次数为一
++color_count[color];
}
size_t sum = 0;
for(const auto &c : color_count)
{
if(c.second > sum)
s = c.first;
}
return s;
}
int main()
{
int n;
string color;
while(cin >> n && n != 0)
{
color = foo(n);
cout << color << endl;
    }
return 0;
}

以上介绍了“ 航电1004题”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3626947.html

相关图片

相关文章