Let the Balloon Rise

Let the Balloon Rise

题意:就是找到颜色最多的那个气球的颜色并且输出~
那么颜色和次数之间是有关系的~
很容易想到用map<string ,int >;

#include<bits/stdc++.h>

using namespace std;
int main(){
	map<string,int> count;
	int n;
	int max = 0;
	string pop;
	while(cin>>n && n){
		while(n--){
			string color;
			cin>>color;
			count[color]++;
			if(count[color] > max){
				max = count[color];
				pop = color;
			}
		}
		cout<<pop<<endl;
		max = 0;
	} 
	return 0;
}
全部评论

相关推荐

06-25 16:25
梧州学院 Java
愿汐_:项目介绍那么长,然而你做了啥就一句话?
点赞 评论 收藏
分享
06-08 22:25
门头沟学院 Java
从零开始的转码生活:这hr不会打开手机不分青红皂白给所有人群发这句话,过一会再给所有人再发一遍,这肯定会有重复的,不管,再过一会再发一遍
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务