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. 02_Jquery_04_属性选择器

    [简述] [index.jsp] <%@ page language="java" import="java.util.*" pageEncoding=& ...

  2. 常用数据结构[OpenCV 笔记12]

    Point 二维坐标系下的整数点, 定义如下 typedef Point_<int> Point2i; typedef Point2i Point; typedef Point_<f ...

  3. bzoj1688: [Usaco2005 Open]Disease Manangement 疾病管理

    思路:状压dp,枚举疾病的集合,然后判断一下可行性即可. #include<bits/stdc++.h> using namespace std; #define maxs 400000 ...

  4. 转(sphinx 多索引使用 方法 )

    1 http://blog.csdn.net/adparking/article/details/7080278  文章不错 总结 1.索引合并问题,前面已经解释过,两个索引合并时,都要读入,然后还要 ...

  5. mini2440移植uboot-2008.10 遇到的问题

    1.mkimage的使用(u-boot-2008.10/tools/mkimage) 首先./mkimage 运行或者 将mkimage 拷贝到 /bin 目录下面 法一: #mkimage -n ' ...

  6. IE 动态绑定click事件

    //必须先清除原有的事件 $(dom).attr("onclick", ""); //再重新绑定新的事件 $(dom).bind("click&quo ...

  7. 记录创建企业Wiki的几个开源项目

    很多著名的企业Wiki都是开源产品,如Foswiki(基于Perl),TWiki(基于Perl)等,另外有Mindtouch(基于PHP, C#),Confluence(基于Java)等.维基道的Wi ...

  8. Python中的redis学习笔记

    redis是一个key-value结构的数据库,value的格式可以使string,set,list,map(即python里面的dict),sorted set(有序集合) 1.初始化 1)直接连接 ...

  9. c语言的笔记

    下面把我这半年来记的一些C语言的笔记贴出来. 1  C语言中函数参数传递是按照“值传递”进行的,即单向传递. 2  函数原型:函数类型 函数名(参数类型,参数类型……),可以不必加参数名,因为操作系统 ...

  10. web服务编码设置

    response设置编码. <%@ page contentType="text/html;charset=UTF-8" %> 是服务器端java程序运行时的输出编码, ...