hdoj 1004 Let the Balloon Rise
2014-07-22 13:03
387 查看
#include<stdio.h>
#include<string.h>
int main()
{
int T,i,j,k,max;
while(scanf("%d",&T)&&T!=0)
{
max=0;
struct Color
{
char s[200];
int n;
}color[2000];
for(i=0;i<T;i++)
scanf("%s",color[i].s);
for(i=0,color[i].n=0;i<T;i++)//每种颜色的个数color[i].n
{
for(j=0;j<T;j++)
{
if(strcmp(color[i].s,color[j].s)==0)
color[i].n+=1;
}
}
/*for(i=0;i<T;i++)//输出每种颜色出现的个数
printf("%d ",color[i].n);
printf("\n");
*/
for(i=0;i<T;i++)//颜色出现次数最多的数组名赋给k
{
if(color[i].n>max)
{
max=color[i].n;
k=i;
}
}
printf("%s\n",color[k].s);
for(i=0;i<T;i++)//颜色的个数归零
color[i].n=0;
}
//while(1);
return 0;
}
#include<stdio.h>
#include<string.h>
int main()
{
int T,i,j,k,max;
while(scanf("%d",&T)&&T!=0)
{
max=0;
struct Color
{
char s[200];
int n;
}color[2000];
for(i=0;i<T;i++)
scanf("%s",color[i].s);
for(i=0,color[i].n=0;i<T;i++)//每种颜色的个数color[i].n
{
for(j=0;j<T;j++)
{
if(strcmp(color[i].s,color[j].s)==0)
color[i].n+=1;
}
}
/*for(i=0;i<T;i++)//输出每种颜色出现的个数
printf("%d ",color[i].n);
printf("\n");
*/
for(i=0;i<T;i++)//颜色出现次数最多的数组名赋给k
{
if(color[i].n>max)
{
max=color[i].n;
k=i;
}
}
printf("%s\n",color[k].s);
for(i=0;i<T;i++)//颜色的个数归零
color[i].n=0;
}
//while(1);
return 0;
}
相关文章推荐
- HDOJ1004 Let the Balloon Rise(字符串——次数统计)
- HDOJ 1004 Let the Balloon Rise
- 【HDOJ】【1004】Let the Balloon Rise
- HDOJ 1004 Let the Balloon Rise
- HDOJ 1004 Let the Balloon Rise
- hdoj 1004 Let the Balloon Rise(map)
- hdoj 1004 Let the Balloon Rise 【STL or 暴力】
- HDOJ杭电1004 Let the Balloon Rise
- ACM--模拟--气球出现次数--HDOJ 1004--Let the Balloon Rise--水
- HDOJ 1004 Let the Balloon Rise
- HDOJ 1004 Let the Balloon Rise(字符串)
- HDOJ 1004 Let the Balloon Rise
- (HDOJ 1004)Let the Balloon Rise
- HDOJ 1004 Let the Balloon Rise
- HDOJ Let the Balloon Rise 1004
- hdoj 1004 Let the Balloon Rise 解题报告
- HDOJ-1004 Let the Balloon Rise
- hdoj 1004 Let the Balloon Rise(模拟 || 字典树)
- HDOJ - 1004 - Let the Balloon Rise(字符串)
- hdoj1004 Let the Balloon Rise(map)