Let the Balloon Rise

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 74110    Accepted Submission(s):
27711

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
 
 
字符串的比较:两个数组color[1005][16]和num[1005]。数组color是用来保存颜色的,数组num是用来保存颜色出现的次数,最后求出数组num中最大的数的下标即为出现次数最多的颜色。
 
 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char color[][];
int num[];
int main()
{
int n, i, j, max;
while(scanf("%d",&n) && n)
{
for (i=; i<n; i++)
scanf("%s",&color[i]);
for(i=; i<; i++)
num[i] = ;
for(i=; i<n; i++)
for(j=; j<i; j++)
if(strcmp(color[i],color[j])==)
num[i]++;
max = ;
j = ;
for(i=; i<n; i++)
if (max<num[i])
{
max = num[i];
j = i;
}
printf("%s\n",color[j]);
}
return ;
}

hdu 1004 Let the Balloon Rise的更多相关文章

  1. 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 ...

  2. 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 ...

  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. HDU 1004 Let the Balloon Rise map

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

  5. 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 ...

  6. hdu 1004 Let the Balloon Rise 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 用STL 中的 Map 写的 #include <iostream> #includ ...

  7. HDU 1004 - Let the Balloon Rise(map 用法样例)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  8. HDU 1004 Let the Balloon Rise(map应用)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  9. HDU 1004 Let the Balloon Rise(STL初体验之map)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

随机推荐

  1. 基于UDP协议的socket编程示例

    客户端 import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; impo ...

  2. 运用ASP.NET实现

    calation.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; /// ...

  3. thinkphp2

  4. WPF整理-使用逻辑资源

    "Traditional application resources consist of binary chunks of data, typically representing thi ...

  5. MySQL 事务

    MySQL 事务主要用于处理操作量大,复杂度高的数据.比如说,在人员管理系统中,你删除一个人员,你即需要删除人员的基本资料,也要删除和该人员相关的信息,如信箱,文章等等,这样,这些数据库操作语句就构成 ...

  6. Linux下安装Git

    Ubuntu12.04中默认没有安装Git.需要自行安装. 1. 安装Git 1.1 Ubuntu12.04下 可以使用apt-get方式安装,也可以下载源代码安装[1],我们这里使用apt-git安 ...

  7. Powershell获取磁盘信息

    使用Powershell完成系统管理实在是太方便了,磁盘信息获取只需几行代码即可. 1: $DiskCount = ((Get-WmiObject -Class Win32_DiskDrive).Ca ...

  8. FJNU 1196 汪老司机(DP or 建图+最短路)

    1196: 汪老司机 Time Limit: 1000 MS         Memory Limit: 257792 KB 64-bit interger IO format: %lld       ...

  9. [不好分类]SD卡无法读取,显示RAW

    上周同事拿来了一个8G的SD卡,插入读卡器后显示“需要格式化”.无法读取.文件格式处显示“RAW”,磁盘大小显示0字节. 处理步骤如下: 1.按照提示,格式化,选择“快速格式化”. 2.采用数据恢复软 ...

  10. alfresco category searches...

    From page 475 of the Alfresco Developer Guide- Category searches use the PATH field, but you constru ...