HDU-1004 Let the Balloon Rise

简介: HDU-1004 Let the Balloon Rise

题目:

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

解析:

1.使用c++ STL中的map类模板

#include 
#include 
#include 
using namespace std;
int main(){
map Ballon;
string color, popuColor;
int n, max;
while(cin>>n&&n){
    Ballon.clear();
    while(n--){
        cin>>color;
        Ballon[color]++;
    }
    map::iterator it;
    max = 0;
    for(it=Ballon.begin(); it!=Ballon.end(); it++){
        if(it->second>max){
            max = it->second;
            popuColor = it->first;
        }
    }
    cout<


相关文章
|
人工智能 API
【服务器】搭建ChatGPT站点常见问题
【服务器】搭建ChatGPT站点常见问题
727 0
|
Oracle 关系型数据库 MySQL
第四章:OceanBase集群技术架构(分布式事务、MVCC、事务隔离级别)
第四章:OceanBase集群技术架构(分布式事务、MVCC、事务隔离级别)
742 0
|
监控 数据挖掘 数据安全/隐私保护
ERP系统中的应收应付管理与风险控制解析
【7月更文挑战第25天】 ERP系统中的应收应付管理与风险控制解析
772 2
|
存储 分布式计算 物联网
Apache IoTDB进行IoT相关开发实践
物联网技术带来数据库管理挑战,特别是实时数据整合与安全性。IoTDB是一个专为时间序列数据设计的数据库,提供数据收集、存储和分析服务,适用于海量物联网数据。其架构包括数据文件、系统文件和预写日志文件的管理,并支持多目录存储策略。此外,IoTDB还开发了InfluxDB协议适配器,使得用户能无缝迁移原有InfluxDB业务。此适配器基于IoTDB的Java服务接口,转换InfluxDB的元数据格式,实现与IoTDB的数据交互。目前,适配器支持InfluxDB 1.x版本及部分查询语法。
446 5
|
机器学习/深度学习 算法 搜索推荐
SPSS大学生网络购物行为研究:因子分析、主成分、聚类、交叉表和卡方检验
SPSS大学生网络购物行为研究:因子分析、主成分、聚类、交叉表和卡方检验
|
机器学习/深度学习 算法 数据挖掘
【Python 机器学习专栏】Python 机器学习入门:基础概念与流程
【4月更文挑战第30天】本文介绍了Python在机器学习中的重要性,机器学习的基础概念和分类,包括监督学习、非监督学习和强化学习。Python因其丰富的库(如Scikit-learn、TensorFlow、PyTorch)、简单易学的语法和跨平台性在机器学习领域广泛应用。文章还概述了机器学习的基本流程,包括数据收集、预处理、特征工程、模型训练与评估等,并列举了常用的Python机器学习算法,如线性回归、逻辑回归、决策树和支持向量机。最后,讨论了Python机器学习在金融、医疗、工业和商业等领域的应用,鼓励读者深入学习并实践这一技术。
358 2
|
缓存 算法 编译器
【C/C++ 泡沫精选面试题01】提高c++性能,你用过哪些方式去提升?
【C/C++ 泡沫精选面试题01】提高c++性能,你用过哪些方式去提升?
342 1
C++ 编写DLL文件给易语言调用
  摸索了两天了,终于解决了所有问题,在此跟大家分享。   需要三个文件,dll_demo.h、dll_demo.cpp、dll_dome.def   直接上代码:   头文件如下: 1 #ifndef _DLL_DEMO_H_ 2 #define _DLL_DEMO_H_ 3 #ifdef DL...
2356 0
|
域名解析 运维 负载均衡
【运维知识进阶篇】Tomcat集群实战之部署zrlog博客(Tomcat服务安装+静态资源挂载NFS+Nginx负载均衡+HTTPS证书+Redis会话保持)
【运维知识进阶篇】Tomcat集群实战之部署zrlog博客(Tomcat服务安装+静态资源挂载NFS+Nginx负载均衡+HTTPS证书+Redis会话保持)
605 1
|
运维 监控 Java
【运维知识进阶篇】Zabbix5.0稳定版详解8(Zabbix监控Java项目+详解JMX与Zabbix-Java-Gateway原理+详解监控Java项目流程原理)
【运维知识进阶篇】Zabbix5.0稳定版详解8(Zabbix监控Java项目+详解JMX与Zabbix-Java-Gateway原理+详解监控Java项目流程原理)
847 0