Let the Balloon Rise
来源:互联网 发布:angularjs源码解读 编辑:程序博客网 时间:2024/06/07 19:15
Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.
This year, they decide to leave this lovely job to you.
This year, they decide to leave this lovely job to you.
A test case with N = 0 terminates the input and this test case is not to be processed.
5greenredblueredred3pinkorangepink0
redpink
这道题没什么坑的地方,为什么那么多次不过呢
c语言实现:
#include<stdio.h>#include<string.h>int main(){while(1){int n;scanf("%d",&n);if(n==0)break;else{int i,num[1005]={0},max,maxi,j;char an[1005][20]={0};max=-1;for(i=0;i<n;i++){scanf("%s",an[i]);for(j=0;j<i;j++){if(strcmp(an[j],an[i])==0){num[j]++;if(num[j]>max){max=num[j];maxi=j;}break;}}}printf("%s\n",an[maxi]);}}return 0;}c++实现(string):
#include<iostream>#include<string>using namespace std;int main(){while(1){int n;cin >> n;if(n==0)break;else{int i,num[1005]={0},max,maxi,j;string an[1005];max=-1;for(i=0;i<n;i++){cin >> an[i];for(j=0;j<i;j++){if(an[i]==an[j]){num[j]++;if(num[j]>max){max=num[j];maxi=j;}break;}}}cout << an[maxi] << endl;}}return 0;}c++实现(map):
#include<iostream>#include<string>#include<map>using namespace std;int main(){while(1){int n;cin >> n;if(n==0)break;else{int i,num[1005]={0},max;map <string,int> mp;max=-1;for(i=0;i<n;i++){string str;cin >> str;mp[str]++;}string res;map <string,int>::iterator it;for(it=mp.begin();it!=mp.end();it++){if(it->second>max){max=it->second;res=it->first;}}cout << res << endl;}}return 0;}
阅读全文
0 0
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the balloon rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- QSQLITE使用整理,sql常用语句
- MySQL 管理
- C#Lab(一):结构体包含引用、结构体实现接口后是引用类型还是值类型
- Ignatius and the Princess I HDU
- MySQL 连接
- Let the Balloon Rise
- XCode8.3.3更新失败
- STM32——优先级NVIC_PriorityGroupConfig的理解及其使用
- MySQL 创建数据库
- 6.截图
- Ulua使用DoTween教程
- MySQL 删除数据库
- 如何选择开源许可协议(一):了解协议
- LightOJ 1248Dice (III)