1004:Let the Balloon Rise
来源:互联网 发布:自助发稿源码 编辑:程序博客网 时间:2024/05/23 11:22
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004
方法:二维数组
思路:用二维数组记录表示颜色的字符串,这是一个比较好的思路,简单,但是可以解决问题,当然也可以用vector,不过二维数组显然是够用了,这种方法应该重视起来。
难点:比较的时候数组下标要从1开始,以便于与前面的字符串比较。
#include<cstdio>#include<string.h>#include<algorithm>using namespace std;int main(){ char color[1000+10][15+5]; int n; int i; while(~scanf("%d",&n)) { if(n == 0) break; int num[1000+10] = {0}; for( i = 0;i < n;i++) scanf("%s",color[i]); for(i = 1;i < n;i++) { for(int j = 0;j < i-1;j++) { if(strcmp(color[i],color[j]) == 0) { num[i]++; } } } int maxnum = 0; int t = 0; for(i = 0;i < n;i++) { if(num[i]>maxnum) { maxnum = num[i]; t = i; } } printf("%s\n",color[t]); }}
0 0
- 1004 Let the Balloon Rise
- 1004 Let the Balloon Rise
- 1004 Let the Balloon Rise
- 1004let the balloon rise
- Let the Balloon Rise 1004
- 1004 Let the Balloon Rise
- Let the Balloon Rise(1004)
- 1004Let the Balloon Rise
- Let the Balloon Rise(1004)
- Let the Balloon Rise(1004)
- 1004:Let the Balloon Rise
- 1004 let the balloon rise
- 1004 Let the Balloon Rise
- 1004 Let the Balloon Rise
- 1004-Let the Balloon Rise
- 1004 Let the Balloon Rise
- 1004 Let the Balloon Rise
- 1004 Let the Balloon Rise
- 2015年多校联合训练第四场(Olympiad)hdu5327
- java concurrent并发详解
- TCP/IP概述
- hdu 5290 Bombing plan(树形dp)
- 剑指offer面试题36数组中的逆序对数
- 1004:Let the Balloon Rise
- CXF开发RESTFUL的实例练习
- C语言深度解剖——读书笔记-1、关键字
- I2C通信一般性问题
- Android -- 绑定服务
- poj 3365 数学分类(最大的圆柱体积)
- mongodb索引
- HDU doing homework again
- zoj 3874 Permutation Graph (cdq分治+NTT)