ACM1004 Let the balloons fly
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的更多相关文章
- 第一届山东省ACM——Balloons(java)
Description Both Saya and Kudo like balloons. One day, they heard that in the central park, there wi ...
- Balloons(山东省第一届ACM省赛)
Balloons Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Both Saya and Kudo like balloons ...
- sdutoj 2152 Balloons
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2152 Balloons Time Limit: ...
- CodeForces - 725D Contest Balloons 贪心
D. Contest Balloons time limit per test 3 seconds memory limit per test 2 ...
- sdut 2152:Balloons(第一届山东省省赛原题,DFS搜索)
Balloons Time Limit: 1000MS Memory limit: 65536K 题目描述 Both Saya and Kudo like balloons. One day, the ...
- 【37.74%】【codeforces 725D】Contest Balloons
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...
- [LeetCode] Burst Balloons 打气球游戏
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by ...
- 图论 - 寻找fly真迹
一天fly正坐在课堂上发呆,突然,他注意到了桌面上的一个字符串S1S2S3S4...Sn,这个字符串只由字符"a","b"和"c"构成.刚好 ...
随机推荐
- Centos7下安装mysql服务
yum install -y perl-Module-Install.noarch yum -y install perl perl-devel #命令下载mysql wget http://dev. ...
- usdt信息小结
https://blog.csdn.net/weixin_42208011/article/details/80499536 https://blog.csdn.net/weixin_42208011 ...
- Linux下安装paramiko
paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接. 由于使用的是python这样的能够跨平台运行的语言,所以所有python支持的平台, ...
- angularJS遇到的坑
最近在用angularjs做一些东西,由于学艺不精,对angularjs了解不够,导致经常会不小心掉进一些自己挖的坑里(⊙_⊙),在这里记下来,谨防又踩. 1.angularjs ng-show no ...
- “Hello world!”团队第三周贡献分规则
一.贡献规则制定: (1)基础分:9 , 9 , 8 , 7 , 7 , 7 , 6(按在本次编程中承担模块的重要度制定,某一模块重要度的认定通过组内开会讨论决定) (2)会议分:每人没出勤一次会议记 ...
- BluetoothSocket详解
一. BluetoothSocket简介 1. 简介 客户端与服务端 : BluetoothSocket 和 BluetoothServerSocket 类似于Java中的套接字的 Socket 和 ...
- lintcode-33-N皇后问题
33-N皇后问题 n皇后问题是将n个皇后放置在n*n的棋盘上,皇后彼此之间不能相互攻击. 给定一个整数n,返回所有不同的n皇后问题的解决方案. 每个解决方案包含一个明确的n皇后放置布局,其中" ...
- 字符串数组去重 ["a","b","c","a","b","c"] --> ["a","b","c"]
非正则实现: let str_arr=["a","b","c","a","b","c&qu ...
- windows批处理学习(字符换操作)---04
转自:https://www.cnblogs.com/DswCnblog/p/5432326.html 1.截取字符串 截取字符串可以说是字符串处理功能中最常用的一个子功能了,能够实现截取字符串中的特 ...
- try catch finally 与continue的使用
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...