hdu1004
This year, they decide to leave this lovely job to you.
A test case with N = 0 terminates the input and this test case is not to be processed.
green
red
blue
red
red
3
pink
orange
pink
0
map<string,int>::iterator j;
for (j=color.begin();j!=color.end();++j)
这个是遍历map的方法
map的初始化问题我还没找到解决的方法 于是此题讲其值直接改为零 找到方法之后我来更新
//
// main.cpp
// hdu1004
//
// Created by tupeihui on 15/12/6.
// Copyright © 2015年 admin. All rights reserved.
// #include <iostream>
#include <map>
using namespace std;
map<string,int> color;
char s[];
int main() {
int n; while (scanf("%d",&n))
{
if (n==) break;
for (int i=;i<=n;i++)
{
scanf("%s",s);
color[s]+=;
}
map<string,int>::iterator j;
int ans=;
string anss;
for (j=color.begin();j!=color.end();++j)
{
if (j->second > ans)
{
ans=j->second;
anss=j->first;
}
color[j->first]=;
}
cout<<anss<<endl; }
return ;
}
hdu1004的更多相关文章
- HDU1004 (数组元素出现最多)
HDU1004 思路:求数组中出现次数最多的那个元素: 遍历数组元素,找出每个元素出现的次数 Input Input contains multiple test cases. Each test c ...
- HDU1004之总是wa的细节问题
#include <stdio.h> #include <string.h> int main() { ][]; int n, i, k, j, max, max_i; ){ ...
- HDU1004 BALLO0N
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU1004 查气球
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- HDU1004 Let the Balloon Rise(map的简单用法)
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU1004题解分析(字符串处理)
这道题是从上个星期开始做的,看到题时觉得似曾相似,好像做过,理了一下思路敲完代码又不对,后来发现是数组用错了,之后又重新想了数组和比较用法,昨天改了一个多小时,后来样例输出全部正确,所有情况都考虑到了 ...
- [HDU1004] Let the balloon rise - 让气球升起来
Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...
- 字符串处理-Hdu1004
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 题目大意:给你一个数n,要求输入n个字符串,在这n个字符串中,我们需要输出出现次数最多的字符串. ...
- HDU-1004.Let the ballon Rise(STL-map)
2019-02-28-08:56:03 初次做本题是用字符串硬钢,最近校队训练时又遇到才知道用map是真的舒服.需要注意的是map的用法. clear : 清除map中的所有元素,map.clear( ...
随机推荐
- Javascript学习笔记2.2 Javascript与DOM选项卡(滑动门)案例详解
学习了DOM的知识,今天开始做些练习,想到了一个网页滑动门的特效,见下图: 1.通过建立索引实现 <!doctype html> <html> <head> < ...
- Oracle通过一个Value值查询数据库
---恢复内容开始--- 大家在想看看数据库中有哪些数据表中,哪些字段中有“helloworld” 这个字符串,现在数据库所有的表,视图都不能直接提供,所有必须通过循环去访问所有的数据表,所有的字段列 ...
- 新手使用django-pagination分页
首先使用pip instal pagination 即可完成安装. (pycharm里就是安装个django-pagination外包) 完成后配置如下: 1. 将安装文件中的 pagination ...
- maven私服搭建(centOS6.5)
maven的好处和私服的应用本文不赘述,私服搭建如下: MAVEN 私服搭建(centOS 6.5 环境) 1. 准备环境,搭建centOS6.5系统环境,略 2. 准备对应的软件包如下: A. ...
- Node.js的cluster模块——Web后端多进程服务
众所周知,Node.js是单线程的,一个单独的Node.js进程无法充分利用多核.Node.js从v0.6.0开始,新增cluster模块,让Node.js开发Web服务时,很方便的做到充分利用多核机 ...
- placeholder 使用
这个属性是用于INPUT当中. 实现效果: 1.鼠标点击进入<input type='buttom' placeholder='用户名'> 2.用户名内容消失:不在使用以前的Value,来 ...
- LeetCode 4 Median of Two Sorted Arrays 查找中位数,排除法,问题拓展 难度:1
思路:设现在可用区间在nums1是[s1,t1),nums2:[s2,t2) 1.当一个数组可用区间为0的时候,由于另一个数组是已经排过序的,所以直接可得 当要取的是最小值或最大值时,也直接可得 2. ...
- 100. Same Tree
[题目] Given two binary trees, write a function to check if they are equal or not. Two binary trees ar ...
- 更新证书错误:No matching provisioning profiles found
在Xcode中当你在更新了你得证书而再重新编译你的程序,真机调试会出现“Your build settings specify a provisioning profile with the UUID ...
- 读取.properties配置文件
方法1 public class SSOUtils { protected static String URL_LOGIN = "/uas/service/api/login/info&q ...