HDU 1004 Let the Balloon Rise
来源:互联网 发布:淘宝家纺拍摄 编辑:程序博客网 时间:2024/05/16 05:00
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7259 Accepted Submission(s): 2109
Problem Description
This year, they decide to leave this lovely job to you.
Input
A test case with N = 0 terminates the input and this test case is not to be processed.
Output
思路:
每输入一种颜色,就拿去跟已有的颜色匹配,若匹配成功,则该颜色的num加1,否则,将该颜色加入颜色数组中去。
贴下代码:
#include<stdio.h>
#include<string.h>
struct color
{
int num;
char StrColor[20];
}color[1000];
int Max,maxI;
void clear()
{
int i;
for(i=0;i<1000;i++)
{
color[i].num=0;
strcpy(color[i].StrColor,"");
}
}
int main()
{
int n;
int NumOfColor;
char TempColor[20];
while(EOF!=scanf("%d",&n)&&n)
{
int i,j,flag;
clear();
scanf("%s",TempColor);
strcpy(color[0].StrColor,TempColor);
color[0].num=1;
NumOfColor=1;
for(i=1;i<n;i++)
{
scanf("%s",TempColor);
flag=1;
for(j=0;j<NumOfColor&&flag;j++)
{
if(!strcmp(TempColor,color[j].StrColor))
{
color[j].num++;
flag=0;
}
}
if(flag)
{
strcpy(color[NumOfColor++].StrColor,TempColor);
color[NumOfColor-1].num=1;
}
}
Max=color[0].num;
maxI=0;
for(i=1;i<NumOfColor;i++)
{
if(color[i].num>Max)
{
Max=color[i].num;
maxI=i;
}
}
printf("%s/n",color[maxI].StrColor);
}
return 0;
}
- HDU 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU--1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- Hdu 1004 - Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU--1004--Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise STL
- 解决SQL SERVER 2005EXPRESS 无法连接服务器错误
- Ext2.2-用XML做数据源,可编辑Grid的例子
- 怎样使用AJAX进行WEB应用程序开发
- 28条讨人喜欢的原则
- 关于六种Java异常处理程序的陋习
- HDU 1004 Let the Balloon Rise
- 生病
- Struts1.x(二)
- 迷宫问题
- ListRows
- 美化VC界面(用户登录界面)
- vCard 3.0学习笔记
- Struts 中jsp页面导入.css样式文件的问题
- 关于Parallels Workstation 启动蓝屏