码迷,mamicode.com
首页 > 其他好文 > 详细

Hdu oj 1004 Let the Balloon Rise

时间:2015-08-08 18:18:27      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:

分析:用二维数组存放字符串,另外在比较count[i]的大小时,注意保留数组的下标。

#include<stdio.h>
#include<string.h>
char str[1010][16];
int count[1010];
int main()
{
	int m;
	while(scanf("%d",&m),m)
	{
		
		int i,j;
		int max,k;
		for(i=0;i<m;i++)
		scanf("%s",str[i]);
		memset(count,0,sizeof(count));
		for(i=0;i<m;i++)
		   for(j=0;j<m;j++)
		   {
		   	if(strcmp(str[i],str[j])==0)
		   	{
		   		count[i]++;
		   	}
		   }
		   max=count[0];
		   k=0;
		   for(i=0;i<m;i++)
		   {
		   	  if(max<count[i])
		   	  {
		   	  	max=count[i];
		   	  	k=i;
		   	  }
		   }
		   printf("%s\n",str[k]);
		   
	}
	return 0;
}


 

版权声明:本文为博主原创文章,未经博主允许不得转载。

Hdu oj 1004 Let the Balloon Rise

标签:

原文地址:http://blog.csdn.net/zm_11/article/details/47360497

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!