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

Let the balloons fly

时间:2014-06-09 13:33:35      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:c   code   a   color   int   string   

These code is for the problem "Let the balloons Fly" in ACM 1004 which need deal with string.

It is a little difficult in some content so that I rewrite it here to let more confused students have access to it.

It can be accepted by handing it in G++.

 

 

#include<iostream>
#include<cstring>
using namespace std;
string judge(int len)
{
int i,j,n=0;
string color[1000],colo[1000];
int co[1000]={0};
for(i=0;i<len;i++)
{
cin>>color[i];
}


for(i=0;i<len;i++)
{
colo[i]=color[i];
for(j=0;j<len;j++)
{
if(colo[i]==color[j])
co[i]++;
}
}
int num;
num=co[0];n=0;
for(i=1;i<len;i++)
{
if(num<co[i])
{n=i;
num=co[i];
}
}
return color[n];
}
int main()
{
int n;
int i=0;
string yanse[1000];
cin>>n;
while(n!=0)
{
yanse[i]=judge(n);
i++;
cin>>n;
}
for(n=0;n<i;n++)
cout<<yanse[n]<<endl;
return 0;
}

Let the balloons fly,布布扣,bubuko.com

Let the balloons fly

标签:c   code   a   color   int   string   

原文地址:http://www.cnblogs.com/sytu/p/3776860.html

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