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;
}

ACM1004 Let the balloons fly的更多相关文章

  1. 第一届山东省ACM——Balloons(java)

    Description Both Saya and Kudo like balloons. One day, they heard that in the central park, there wi ...

  2. Balloons(山东省第一届ACM省赛)

    Balloons Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Both Saya and Kudo like balloons ...

  3. sdutoj 2152 Balloons

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2152 Balloons Time Limit: ...

  4. CodeForces - 725D Contest Balloons 贪心

              D. Contest Balloons          time limit per test 3 seconds         memory limit per test 2 ...

  5. sdut 2152:Balloons(第一届山东省省赛原题,DFS搜索)

    Balloons Time Limit: 1000MS Memory limit: 65536K 题目描述 Both Saya and Kudo like balloons. One day, the ...

  6. 【37.74%】【codeforces 725D】Contest Balloons

    time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...

  8. [LeetCode] Burst Balloons 打气球游戏

    Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by ...

  9. 图论 - 寻找fly真迹

    一天fly正坐在课堂上发呆,突然,他注意到了桌面上的一个字符串S1S2S3S4...Sn,这个字符串只由字符"a","b"和"c"构成.刚好 ...

随机推荐

  1. 【转】MMO即时战斗:技能实现

    转自 http://blog.csdn.net/cyblueboy83/article/details/41628743 一.前言 基本所有MMO游戏无论是回合制.策略类.即时战斗等等类型都需要有相应 ...

  2. 深度学习笔记 (二) 在TensorFlow上训练一个多层卷积神经网络

    上一篇笔记主要介绍了卷积神经网络相关的基础知识.在本篇笔记中,将参考TensorFlow官方文档使用mnist数据集,在TensorFlow上训练一个多层卷积神经网络. 下载并导入mnist数据集 首 ...

  3. java常见的异常类型

    Exception分为两类:非运行是异常和运行时异常. java编译器要求方法必须声明抛出可能发生的非运行时异常,但是并不要求必须声明抛出未被捕获的运行时异常.A:NullPointerExcepti ...

  4. Windows下PATH等环境变量详解(转载)

    本文转载自http://legend2011.blog.51cto.com/3018495/553255 在学习JAVA的过程中,涉及到多个环境变量(environment variable)的概念, ...

  5. 常用正则表达式,你要的都在这里(校验字符,数字,特殊需求qq,电话等)

    一.校验数字的表达式 1 数字:^[0-9]*$ 2 n位的数字:^\d{n}$ 3 至少n位的数字:^\d{n,}$ 4 m-n位的数字:^\d{m,n}$ 5 零和非零开头的数字:^(0|[1-9 ...

  6. 【转】Hbuilder MUI 页面刷新及页面传值问题

    文章来源:http://www.111cn.net/sys/CentOS/67213.htm 一.页面刷新问题 1.父页面A跳转到子页面B,B页面修改数据后再跳回A页面,刷新A页面数据 (1).父页面 ...

  7. 团队作业7——第二次项目冲刺-Beta版本项目计划

    上一个阶段的总结: 在Alpha阶段,我们小组已近完成了大部分的功能要求,小组的每一个成员都发挥了自己的用处.经过了这么久的磨合,小组的成员之间越来越默契,相信在接下来的合作中,我们的开发速度会越来越 ...

  8. iOS开发跳转指定页面

    for (UIViewController *VC in self.navigationController.viewControllers) { if ([VC isKindOfClass:[Car ...

  9. linux系统中如何进入退出vim编辑器的方法及区别

    在linux家族中,vim编辑器是系统自带的文本编辑器,其功能强大自不必说了. 偶有小白,刚接触linux,要修改某个文本文件,不可能像WINDOWS那样操作,更有甚者,进入VI编辑器后,无法退出以致 ...

  10. xpath教程三---逐层检索和全局检索

    本节主要介绍用xpath来描述html的层级关系 主要使用到的知识点如下: 单独的一个点 .,表示当前位置 两个点 ..,表示上一级父标签的位置 单独的一个斜杠 /,表示只检索下面一级 单独的两个斜杠 ...