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. ssh命令:隧道代理+本地端口转发+远程端口转发

        0.前言 nc是一个在网络连接两端的好工具,同时也是也个临时的端口转发的好工具.(永久的端口转发用什么?用iptables) ssh也是这方面的好工具,好处是加密可靠可复用在一端操作即可,代价 ...

  2. Git---Git及GitHub使用笔记

    一.远程项目获取(克隆) syntax: $ git clone <版本库的网址> $ git clone <版本库的网址> <本地目录名> example: $ ...

  3. dom三个事件

    1,页面加载后 window.onload=function(){}; 2,页面(关闭)卸载后触发 window.onunload=function(){}; 3,页面关闭前触发 window.onb ...

  4. jquery插件----文件上传uploadfile

    使用了一款jquery上传的插件,ajax上传,可以显示上传的进度,高可配性,简要记录. 插件地址http://hayageek.com/docs/jquery-upload-file.php git ...

  5. cygwin下的第一次编程记录

    今天在window7上安装了cygwin,体验了一把unix,编了个小c,c++程序 先把过程记录下来 1.先删除以前建立的source文件夹 rm -rf source linux删除目录很简单,很 ...

  6. jquery点击图片选中特效

    jquery点击图片选中特效 点击在线预览效果

  7. 不用第三个变量,将a,b两个值互换,会出现什么样的异常?

    1 相互加减 a = a + b; b = a - b; a = a - b; 但会出现异常 如果a+b超过a类型的范围,俗称溢出异常. 2 指针操作交换地址 3 异或操作 转自网络搜索的答案

  8. Re-installation failed due to different application signatures./package name has exist

    http://www.cnblogs.com/qianxudetianxia/archive/2011/04/09/2010468.html

  9. Ubuntu/Linux下7款轻量级编辑器 (转)

    From http://www.feiyan.info/39.html 在Windows卧铺使用Zend Studio或者EditPlus写PHP,Zend Studio适合大项目,EditPlus配 ...

  10. IEEE二进制浮点数算术标准(IEEE 754)

    整理自IEEE 754 IEEE二进制浮点数算术标准(IEEE 754)是20世纪80年代以来最广泛使用的浮点数运算标准,为许多CPU与浮点运算器所采用.这个标准定义了表示浮点数的格式(包括负零-0) ...