杭电OJ 1004 Let the Balloon Rise

杭电OJ | 1004 Let the Balloon Rise 结构体数组排序 1004Let the Balloon Rise 笔记:用memset对整个结构体数组进行初始化 如果结构体变量都是一致的,比如: struct person{ int age; int cost; }; person per[10]; memset(per,0,sizeof(person)*10); 但是不一致就像下面的代码一样逐一遍历吧,因为如果在结构体定义时就... 阅读详情

                                  Let the Balloon Rise

                          Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
                                             Total Submission(s): 158371    Accepted Submission(s): 62950

Problem Description

Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.

This year, they decide to leave this lovely job to you. 

Input

Input contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case letters.

A test case with N = 0 terminates the input and this test case is not to be processed.

Output

For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case.

Sample Input

5
green
red
blue
red
red
3
pink
orange
pink
0

Sample Output

red
pink

Author

WU, Jiazhi


#include <iostream>
#include <cstring>
#include <string>
using namespace std;
#define MAX 1001
void getNum(int n);
int main()
{
	int n;
	while(cin>>n)
	{
		if(n==0)
		{
			break;	
		}	
		getNum(n);
	}
    return 0;
}
void getNum(int n) 
{
	int i,j;
	int ball[MAX];
	string balloon[MAX];
	memset(ball,0,sizeof(ball));
	for(i=1;i<=n;i++)
	{
		cin>>balloon[i];
	}
	for(i=1;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			if(balloon[i]==balloon[j])
			{
				ball[i]++;
			}
		}
	}
	int maxNum,ret;
	ret=1;
	maxNum=ball[1];
	for(i=2;i<=n;i++)
	{
		if(ball[i]>maxNum)
		{
			maxNum=ball[i];
			ret=i;
		}
	}
	cout<<balloon[ret]<<endl;
}

 

解决Cursor AI工具地域限制报错的方法与原理 地理围栏(GEO-fencing)是现代云服务常用的访问控制技术,通过IP地址库匹配、支付系统验证等方式实现区域限制。在AI编程工具领域,这种技术常导致类似Cursor出现的'unsupported country region'报错。从技术实现看,服务商会综合HTTP头信息、时区设置等多维度数据进行地理位置判断。开发者可通过调整网络出口、配置本地模型或使用企业版等方案解决。本文以Cursor为例,详细分析了AI工具地域限制的底层原理,并提供了包括Ollama本地部署在内的多种工程实践方案,特别适合需要稳定 阅读详情

相关推荐

图神经网络实战(2)——图论基础

图论 (Graph theory) 是数学的一个基本分支,涉及对图研究。图是复杂数据结构的可视化表示,有助于理解不同实体之间的关系。图论提供了大量建模和分析现实问题的工具,如交通系统、社交网络和互联网等。在本节中,将介绍图论的基本原理,主要涉及三个方面:图属性、图概念和图算法。

盼小辉丶的博客 1万+

杭电oj -1004 Let the Balloon RiseC++) STL

分析:用set容器存键值和实值 输出实值最大的对应的key #include &lt;iostream&gt; #include &lt;map&gt; #include &lt;string&gt; using namespace std; int main() { map&lt;string,int&gt; m; string color; int n; while(cin &gt;...

散仙 481

上市公司体制试点数据集DID(2000-2024).xlsx

详细介绍及样例数据:https://blog.csdn.net/T0620514/article/details/160713143

杭电oj-------1004 Let the Balloon Rise

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1004 解题思路:可以将输入的单词存在map容器里面,如果相同的话就累加,再与初设值max=0相比较,找出出现次数最多的单词,输出出来#include #include #include using namespace std; int main() { int n,max=0; s

yiyuqingning的博客 386

Hdu Let the Balloon Rise

Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest i

lnlnlnying的博客 469

hduOJ1004 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): 147124Accepted Submission(s): 58434 Problem Description Contest ti...

weixin_30706691的博客 197

杭电oj-1004Let the Balloon Rise

比较简单的方法是用map来存储每个字符串以及统计出现的次数,最后再求map中value值最大的元素。输入字符串数量n,若n不为0则继续输入n个字符串,求出现次数最多的字符串,若n为0则退出。个人学习经验,欢迎各位指导。

weixin_51670979的博客 1515

杭电oj 1004 Let the Balloon Rise

【代码】杭电oj 1004 Let the Balloon Rise

ZIM的博客 402

杭电oj HDOJ 1004 Let the Balloon Rise

杭电oj HDOJ 1004 Let the Balloon Rise Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges’ favorite time is guessing the most ...

qq_39880604的博客 197

杭电OJ 1004——Let the Balloon Rise

#1004 统计字符串找出总数,这道题保证了总数的唯一性,也在一定程度上降低了难度,思路是直接使用字符串数组记录气球的颜色,之后使用一维整数数组统计每个气球颜色出现的次数,找出总数最大的气球。 记录点 字符数组的比较可以使用strcmp函数,如果是字符串的话,直接使用compare函数 题目直达 AC代码 #include <iostream> #include <cmath&g...

Hello_Pepsi的博客 194

杭电oj——1004(java版)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): 118478    Accepted Submission(s): 46433 Problem Description Contes

椰子真的是只猫 772

杭电OJ1004Let the Balloon Rise

解题思路: 1.定义一个二维数组用来储存颜色。 2.从第一个颜色往后比,并记录相同的数量,位置。得到最大值,输出该位置代表的颜色。 代码: #include #include using namespace std; int main() {     int i,j,n,m,c,MAX;     while(cin>>n)     {         if(!n)b

戦う! 302

杭电oj--Let the Balloon Rise1004

输入包含多个测试用例。每个测试用例都以数字 N (0 < N <= 1000) 开头,即分发的气球总数。接下来的 N 行各包含一种颜色。气球的颜色是最多 15 个小写字母的字符串。看到气球飘来飘去是多么兴奋。但告诉你一个秘密,评委们最喜欢的时间是猜最热门的问题。比赛结束后,他们将计算每种颜色的气球并找到结果。对于每种情况,在一行上打印最常见问题的气球颜色。保证每个测试用例都有唯一的解决方案。N = 0 的测试用例终止输入,并且不处理此测试用例。今年,他们决定把这份可爱的工作留给你。

无聊人的博客 452

航电oj1004Let the Balloon Rise

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 155265    Accepted Submission(s): 61685   Problem Description Contest ...

程序员阿浪 387

杭电oj1004 -Let the Balloon Rise(map)

题目链接 原文链接 本来是水题一道,不过发现用数组的话很麻烦,就搜了一下看有没有其他的解法,然后就看到了用map解决的方法,感觉很方便,抄了一下。 利用map的对应关系,不需要在进行颜色比对,很方便。 迭代器也可以像指针一样用 -&gt; 指向成员。 string 比用数组好得多,c++大法好! #include&lt;stdio.h&gt; #include&lt;stdlib....

Dicer_的博客 265

杭电ACM-HDU1004-Let the Balloon Rise

题目来自杭电ACM: acm.hdu.edu.cn Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 93510    Accepted Submission(s): 35712

Soap_egg_pain的博客 2314

杭电ACM—1004 Let the Balloon Rise

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 题目:    Problem Description Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judge

hj1214ing的博客 535

qt,c++为什么要进行序列化和反序列化。已经 1 字节对齐 `#pragma pack(1)`,为什么还要 QDataStream?

qt,c++为什么要进行序列化和反序列化。已经 1 字节对齐 `#pragma pack(1)`,为什么还要 QDataStream?

sunflower_2020的博客 63

c语言分支与循环语句

分支决定程序“走哪条路”,循环决定程序“重复多少次”,跳转语句则负责在必要时改变当前执行节奏。掌握这些语句的语法只是起点,更重要的是理解它们的执行顺序、作用范围和边界条件。当你能够熟练地把ifswitchwhilefordo...whilebreak和continue组合起来,就可以从简单的判断题、循环题,逐步写出登录验证、查找算法和交互式小游戏等完整程序。清晰的控制流,是写出可靠 C 程序的基础。

phltxy的博客 159

C++】线程库

本文系统介绍C++多线程编程:涵盖线程创建、join/detach、this_thread;深入讲解互斥锁(普通、递归、超时、自旋)及RAII管理,对比lock_guard与unique_lock;介绍atomic原子操作与CAS无锁编程;最后详解条件变量,包括生产者-消费者模型、核心API及注意事项,并给出交替打印的实现。

wefg1的博客 194
上一篇: 杭电OJ 1003 Max Sum
下一篇: 杭电OJ 1005 Number Sequence
百事可无乐
博客等级 码龄8年 2粉丝 35原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值