Let the Balloon Rise

问题陈述:

  杭州电子科技大学HANGZHOU DIANZI UNIVERSITY Online Judge Problem - 1004

问题解析:

  输出每组数据中出现次数最多的颜色。

代码详解:  

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4
 5 using namespace std;
 6
 7 int main()
 8 {
 9     int i, j, n, max, count[1000];
10     char balloon[1000][16];
11     while(cin >> n && n!=0) {
12         for(i=0; i<n; i++) {
13             cin >> balloon[i];
14         }
15         for(i=0, max=0; i<n; i++) {
16             count[i] = 0;
17             for(j=i+1; j<n; j++) {
18                 if(strcmp(balloon[i], balloon[j]) == 0) {
19                     count[i]++;
20                 }
21                 max = max > count[i] ? max : count[i];
22             }
23         }
24         for(i=0; i<n; i++) {
25             if(count[i] == max) {
26                 cout << balloon[i] <<endl;
27                 break;
28             }
29         }
30         memset(balloon, 0, sizeof(balloon));
31         memset(count, 0, sizeof(count));
32     }
33     return 0;
34 }

转载请注明出处:http://www.cnblogs.com/michaelwong/p/4280665.html

  

时间: 2024-10-27 09:38:36

Let the Balloon Rise的相关文章

hdu 1004 Let the Balloon Rise

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 80469    Accepted Submission(s): 30293 Problem Description Contest time again! How excited it is to see balloons floating aro

HDU 1004 Let the Balloon Rise【STL&lt;map&gt;】

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 123800    Accepted Submission(s): 48826 Problem Description Contest time again! How excited it is to see balloons floating ar

杭电1004 Let the Balloon Rise

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 120507    Accepted Submission(s): 47270 Problem Description Contest time again! How excited it is to see balloons floating ar

HDU 1004 Let the Balloon Rise map

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 104108    Accepted Submission(s): 40046 Problem Description Contest time again! How excited it is to see balloons floating ar

Let the Balloon Rise(map)

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 91684    Accepted Submission(s): 34910 Problem Description Contest time again! How excited it is to see balloons floating aro

Let the Balloon Rise HDU 1004

Let the Balloon Rise Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 150   Accepted Submission(s) : 63 Problem Description Contest time again! How excited it is to see balloons floating around. B

HDUOJ Let the Balloon Rise 1004

 /* Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 89272    Accepted Submission(s): 33796 Problem Description Contest time again! How excited it is to see balloons float

HDU 1004 Let the Balloon Rise (map使用)

分析:题意简单,就用map的知识即可 #include <stdio.h> #include <iostream> #include <string.h> #include <map> using namespace std; int main() { int i,a,b,k; int N; char num[10]; while (~scanf("%d",&N)) { map<string,int> mp; whil

HDU-1004-Let the Balloon Rise(直接new一个字符串数组compareTo!)

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 85666    Accepted Submission(s): 32330 Problem Description Contest time again! How excited it is to see balloons floating ar

hdoj 1004 Let the Balloon Rise(模拟 || 字典树)

Let the Balloon Rise http://acm.hdu.edu.cn/showproblem.php?pid=1004 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 84401    Accepted Submission(s): 31831 Problem Description Contest time again