Problem Description
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.
Input
Input contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case
letters.



A test case with N = 0 terminates the input and this test case is not to be processed.
Output
For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case.
Sample Input
5
green
red
blue
red
red
3
pink
orange
pink
0
Sample Output
red
pink
代码:
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std; int main()
{
int n,i,j,s=1,b[1010],f[1010];
char a[1010][20];
while(~scanf("%d",&n)&&n)
{
memset(b,0,sizeof(b));
for(i=0; i<n; i++)
{
scanf("%s",a[i]);
}
for(i=0; i<n; i++)
{
f[i]=1;
for(j=i+1; j<n; j++)
{
if(b[j]==0)
{ if(strcmp(a[i],a[j])==0)//这里我不知道为什么用a[i]==a[j]就不可以,求大神评论解释一下,谢谢了
{
b[j]=1;
f[i]=f[i]+1;
}
}
}
}
int s=0;
for(i=0; i<n; i++)
{
if(f[s]<=f[i])
{
s=i;
}
}
printf("%s\n",a[s]);
}
return 0;
}

HDOJ 1004题 Let the Balloon Rise strcmp()函数的更多相关文章

  1. hdu 1004 Let the Balloon Rise strcmp、map、trie树

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

  2. hdu 1004 Let the Balloon Rise

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

  3. HDU 1004 Let the Balloon Rise【STL<map>】

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

  4. Let the Balloon Rise HDU 1004

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

  5. hdu 1004 Let the Balloon Rise(字典树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  6. HDU 1004 Let the Balloon Rise(map的使用)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  7. hdoj-1004-Let the Balloon Rise(水题)

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

  8. hdoj Let the Balloon Rise

     /*Let the Balloon Rise Problem Description Contest time again! How excited it is to see balloons ...

  9. HDUOJ Let the Balloon Rise 1004

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

随机推荐

  1. 幾種方法實現C語言Macro for debug

    1. #include <stdio.h> #include <stdlib.h> #define DEBUG 1 #ifdef DEBUG #define DEBUG_PRI ...

  2. iframe 的基本操作

    要在服务器环境下才行 1.iframe 下操作父页面window.parent.document.getElementById //全部支持window.top //最顶层ie 下的iframe的on ...

  3. WORDPRESS开发(一)自定义页面显示分类目录

    第一步:自定义一个页面,如index.php 第二步:打开index.php文件,引用wp-blog-header.php文件 require('wp-blog-header.php'); 第三步使用 ...

  4. React组件一

    <div id='test'></div> <script type='text/babel'> var Zu=React.createClass({ return ...

  5. php加了命名空间没引入初始化文件:类的命名空间要与文件夹名一致namespace Business\Event;缺少了Event

    php加了命名空间没引入初始化文件:类的命名空间要与文件夹名一致namespace Business\Event;缺少了Event

  6. python分割sql文件

    之前用joomla帮一学校做了个网站,然后要部署到他们到服务器上,他们只提供了sftp和phpmyadmin的账号,上传网站文件倒是挺顺利的,但后来用phpmyadmin导入mysql数据就遇到问题了 ...

  7. C#如何使用ES

    Elasticsearch简介 Elasticsearch (ES)是一个基于 Lucene 的开源搜索引擎,它不但稳定.可靠.快速,而且也具有良好的水平扩展能力,是专门为分布式环境设计的. Elas ...

  8. sql 判断一个表的数据不在另一个表中

    SELECT a.* FROM a LEFT JOIN b ON a.key = b.key WHERE (b.key IS NULL) end as flag from a select id fr ...

  9. 7 -- Spring的基本用法 -- 8...

    7.8 深入理解容器中的Bean 7.8.1 抽象Bean与子Bean 把多个<bean.../>配置中相同的信息提取出来,集中成配置模版------这个配置模版并不是真正的Bean,因此 ...

  10. 什么是马甲APP?怎么用马甲APP导流

    一.什么是马甲APP? 马甲APP指的是为了让认识你的人猜不到,在常用的用户名外再注册的其他名字的APP. 二.马甲APP与真实APP的区别是什么?相同的地方是什么? 1.应用名称不一样. 2.关键词 ...