In this problem we are interested in the frequency of letters in a given line of text. Specifi-cally, we want to know the most
frequently occurring letter(s) in the text, ignoring case (to be clear, “letters” refers precisely to the 26 letters of the alphabet).

Input
Input begins with the number of test cases on its own line. Each test case consists of a single line of text. The line may contain non-letter characters, but is guaranteed to contain at least one letter and less than 200 characters in total.
Output
For each test case, output a line containing the most frequently occurring letter(s) from the text in lowercase (if there are ties, output all such letters in alphabetical order).
Sample Input
1
Computers account for only 5% of the country’s commercial electricity consumption.
Sample Output
co

问题链接:UVA11577 Letter Frequency
问题简述:(略)
问题分析
    统计输入的每一行中各个字母的数量,按字母顺序输出出现频率最高的字母。
    简单的统计题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA11577 Letter Frequency */#include <bits/stdc++.h>using namespace std;const int AN = 26;
const int N = 200;
char s[N + 1];
int cnt[AN];int main()
{int n;scanf("%d", &n);getchar();while(n--) {gets(s);memset(cnt, 0, sizeof(cnt));for(int i = 0; s[i]; i++) {if(islower(s[i]))cnt[s[i] - 'a']++;else if(isupper(s[i]))cnt[s[i] - 'A']++;}int maxf = -1;for(int i = 0; i < AN; i++)maxf = max(maxf, cnt[i]);for(int i = 0; i < AN; i++)if(cnt[i] == maxf)putchar('a' + i);putchar('\n');}return 0;
}

UVA11577 Letter Frequency【文本】相关推荐

  1. Competitive Programming 3题解

    题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...

  2. D3、EChart、HighChart绘图demol

    1.echarts:   <!DOCTYPE html>   <html>   <head>   <meta charset="utf-8" ...

  3. Kaggle---Toxic Comment Classification Challenge

    1.Introduction: 在互联网上匿名有时会让人们说出他们在现实生活中通常不会说的脏话.让我们从我们的平台上过滤掉仇恨,一个一个的评价.最近看了下kaggle上大佬的做法,整理了一下代码,并加 ...

  4. JavaScript权威指南(原书第7版) 犀牛书

    第3章 语法结构 3.10.1 使用let和const声明 ES6后,变量通过let关键字声明 let i let sum 可以使用一条let语句声明多个变量 let i, sum 声明变量的同时,( ...

  5. python统计单词频率、存放在字典中_Python3实现统计单词表中每个字母出现频率的方法示例...

    本文实例讲述了Python3实现统计单词表中每个字母出现频率的方法.分享给大家供大家参考,具体如下: 作为python字典与数组概念的运用,统计字母表中每个字母出现的频率,作为练习再合适不过. 解决问 ...

  6. Python JAVA Solutions for Leetcode

    Python & JAVA Solutions for Leetcode (inspired by haoel's leetcode) Remember solutions are only ...

  7. 英语26个字母使用频度

    Letter Letter name Pronunciation   N Letter Frequency   Letter Frequency A a /ˈeɪ/, /æ/[nb 2]   1 A ...

  8. Go语言(golang)开源项目大全

    http://www.open-open.com/lib/view/open1396063913278.html#Compression 内容目录 Astronomy 构建工具 缓存 云计算 命令行选 ...

  9. 数据库系统概念 实验1~实验9

    数据库系统概念实验1~实验9 本文仅为某咸鱼的实验报告记录,仅供参考,不保证一定正确,也不保证sql语句最优化.代码前斜体部分是本人对实验题目的思路,不保证方法一定最简.部分实验创建表或创建视图的语句 ...

最新文章

  1. 1995年,比尔·盖茨解释什么是互联网
  2. 实验三linux服务与进程管理,Linux 进程与服务管理1
  3. FPGA之道(13)FPGA芯片的应用模式
  4. MultiObjective using Evolutionary Algorithms (2) -- Multi-Objective Optimization
  5. 正则表达式之反向引用
  6. 数据结构之串:KMP算法
  7. 1806. [NOIP2014]无线网路发射器选址
  8. 手机端局部滚动问题 overflow-y:auto
  9. 视频质量评价 VMAF,为何让人又喜又忧?
  10. HuaWei ❀ Radius协议概述
  11. python生成加密exe_python加密保护-加密exe文件
  12. time模块时间格式转换及faker库数据伪造
  13. 深入剖析 redis 事件驱动
  14. Http协议和Python调试过程
  15. 某pdf转word v6.3.0.2算法分析
  16. 分数阶傅里叶变换(FrFT)详细原理与matlab代码实现
  17. DHCP地址池耗尽攻击
  18. 我母亲在一家计算机公司工作,写母亲的作文(精选11篇)
  19. 离线环境安装python第三方库
  20. linux 文件切割

热门文章

  1. Ubuntu Core for Raspberry Pi 使用笔记
  2. 阿里云ECS服务器搭建Nginx+PHP+MySql+Redis环境详细步骤(CentOS7环境)
  3. Sql语句常用关键字
  4. 大学计算机相关理论,大学计算机理论基础 大学计算机基础理论题.doc
  5. 安装不成功_win10+cuda10.1+cudnn+tensorflow1.15.0安装
  6. mongodb 字符串转bson_MongoDB之bson的介绍
  7. Hive 开窗必需掌握的rankdense_rankrow_number
  8. 湖北孝感学校计算机好吗,湖北省孝感市2018年上半年计算机等级考试注意事项...
  9. java 字符串 查找 多个_初学者求教,如何在字符串中查找多个子字符串的位置...
  10. Android系统前台进程,可见进程,服务进程,后台进程,空进程的优先级排序