首页 > 其他 > 详细

Hdu oj 1004 Let the Balloon Rise

时间:2015-08-08 18:15:45      阅读:251      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!