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

hdu-1004

时间:2014-11-04 21:12:27      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:hdu   acm   

很简单的一道题,就是要我们求出最受大家欢迎的题所对应的气球颜色.......


代码如下:


#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
char str[1314][20];
int n,cnt[1314];
int main()
{
    while(cin>>n)
    {
        if(!n)break;
        int ans=0,maxc=0;
        for(int i=0; i<1314; ++i)cnt[i]=0;
        for(int i=0; i<n; ++i)
            cin>>str[i];
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
                if(i!=j)
                    if(!strcmp(str[i],str[j]))
                        cnt[i]++;
            if(cnt[i]>maxc)
                maxc=cnt[i],ans=i;;
        }
        cout<<str[ans]<<endl;
    }
    return 0;
}


hdu-1004

标签:hdu   acm   

原文地址:http://blog.csdn.net/u014004096/article/details/40790927

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