Let the Balloon Rise

时间:2022-07-24
本文章向大家介绍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;
}