URAL 1585. Penguins (字符串)
来源:互联网 发布:windows wep 索引 编辑:程序博客网 时间:2024/05/29 21:33
1585. Penguins
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
Programmer Denis has been dreaming of visiting Antarctica since his childhood. However, there are no regular flights to Antarctica from his city. That is why Denis has been studying the continent for the whole summer using a local cinema. Now he knows that there are several kinds of penguins:
- Emperor Penguins, which are fond of singing;
- Little Penguins, which enjoy dancing;
- Macaroni Penguins, which like to go surfing.
Unfortunately, it was not said in the cartoons which kind of penguins was largest in number. Petya decided to clarify this. He watched the cartoons once more and every time he saw a penguin he jotted down its kind in his notebook. Then he gave his notebook to you and asked you to determine the most numerous kind of penguins.
Input
The first line contains the number n of entries in the notebook (1 ≤ n ≤ 1000 ). In each of the next n lines, there is the name of a kind of penguins, which is one of the following: “Emperor Penguin,” “Little Penguin,” and “Macaroni Penguin.”
Output
Output the most numerous kind of penguins. It is guaranteed that there is only one such kind.
Sample
7Emperor PenguinMacaroni PenguinLittle PenguinEmperor PenguinMacaroni PenguinMacaroni PenguinLittle Penguin
Macaroni Penguin
题意:统计三个字符串哪个出现得最多。
解析:由于每个字符串中间有空格,所以可以用gets直接读取整个字符串,也可以用scanf或cin把它分成两个部分来读。
AC代码:
#include <cstdio>#include <iostream>using namespace std;int main(){ #ifdef sxk freopen("in.txt", "r", stdin); #endif //sxk string s, ss; int n, e, m, l; while(cin>>n){ e = m = l = 0; for(int i=0; i<n; i++){ cin>>s>>ss; if(s[0] == 'E') e ++; else if(s[0] == 'M') m ++; else l ++; } if(e > m && e > l) puts("Emperor Penguin"); else if(m > e && m > l) puts("Macaroni Penguin"); else puts("Little Penguin"); } return 0;}
0 0
- URAL 1585. Penguins (字符串)
- Ural 1585. Penguins
- URAL 1486(二维字符串hash)
- URAL 1612. Tram Forum(字符串啊 )
- 字符串专项:Ural 1723
- 字符串专项:Ural 1102
- 字符串专项:Ural 1354
- 字符串专项:Ural 1423
- URAL 1989 Subpalindromes(字符串HASH&线段树单点更新)
- URAL 1989 Subpalindromes(线段树单点修改+字符串hash)
- uva 12125 - March of the Penguins(最大流)
- UVA 12125 - March of the Penguins(最大流)
- uva 12125 March of the Penguins (最大流)
- 清橙 A1485 Catch The Penguins 抓企鹅(张闻涛)
- Uva 12125 March of the Penguins(最大流)
- URAL 1820 Ural Steaks (贪心)
- URAL - 1820 Ural Steaks(小学生题)
- Ural 1486. Equal Squares 字符串hash
- 写给计算机专业的同学
- epoll_create, epoll_ctl和epoll_wait
- 基于android样式与主题(style&theme)的详解
- jar打包
- Bmob的使用案例
- URAL 1585. Penguins (字符串)
- 嵌入式开发的基础知识
- 在MFC项目中添加控制台调试
- javascript之高级程序设计二
- 【c++程序】输入日期
- java 中 a++ 和 ++a 的区别
- C# 操作SQLServer SMO中遇到的几个问题
- 图像车牌识别(车牌定位与分割部分)
- USACO--1.2Transformations