zoj 2104 Let the Balloon Rise

原创 2012年03月31日 12:36:38
#include "iostream"
#include "string"
#include "vector"
using namespace std;

struct ballons
{
	string color;
	int count;
};

int main()
{
	int N, i;
	vector<ballons> v;
	vector<ballons>::iterator it;
	ballons temp;
	bool tag;
	while (cin >> N && N)
	{
		v.clear();
		for (i = 0; i < N; i++)
		{
			cin >> temp.color;
			temp.count = 1;
			tag = false;
			for (it = v.begin(); it != v.end(); it++)
			{
				if ((*it).color == temp.color)
				{
					(*it).count++;
					tag = true;
				}
			}
			if (!tag)
				v.push_back(temp);
		}
		int max = 0;
		string ans;
		for (it = v.begin(); it != v.end(); it++)
		{
			if ((*it).count > max)
			{
				max = (*it).count;
				ans = (*it).color;
			}
		}
		cout << ans << endl;
	}
}

相关文章推荐

[ACM]Let the Balloon Rise

Problem Description Contest time again! How excited it is to see balloons floating around. But to...

Let the Balloon Rise(hdu 1004)(trie tree)

Let the Balloon Rise(hdu 1004) ACM比赛,裁判们最大的乐趣就是猜所有队伍做出哪道题的数量最多。比赛结束时,他们开始数挂出的哪种颜色气球的数量最多,即知道了他们猜测的结...

Let the balloon rise

Let the Balloon Rise Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Oth...

hdu 1004 Let the Balloon Rise

运用HashMap

[字符串][第二阶段-字符串处理][HDOJ-1004]Let the Balloon Rise

Problem Description Contest time again! How excited it is to see balloons floating around. But to t...

hdu1004 Let the Balloon Rise && hdu1263 水果(map)

主要是想学学map #include #include #include #include #include #include #include #include #include ...

Let the Balloon Rise

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Problem Descri...

hdu 1004 Let the Balloon Rise map的应用

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot...

hdu 1004 Let the Balloon Rise ( trie)

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot...

Let the Balloon Rise hdu1004 字典树

Problem DescriptionContest time again! How excited it is to see balloons floating around. But to tel...
  • jpwang8
  • jpwang8
  • 2017年02月20日 20:02
  • 124
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:zoj 2104 Let the Balloon Rise
举报原因:
原因补充:

(最多只允许输入30个字)