PAT (Basic Level) Practise (中文)1042. 字符统计(20)
来源:互联网 发布:java 生成pdf 下载 编辑:程序博客网 时间:2024/05/22 15:40
1042. 字符统计(20)
时间限制
400 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue
请编写程序,找出一段给定文字中出现最频繁的那个英文字母。
输入格式:
输入在一行中给出一个长度不超过1000的字符串。字符串由ASCII码表中任意可见字符及空格组成,至少包含1个英文字母,以回车结束(回车不算在内)。
输出格式:
在一行中输出出现频率最高的那个英文字母及其出现次数,其间以空格分隔。如果有并列,则输出按字母序最小的那个字母。统计时不区分大小写,输出小写字母。
输入样例:This is a simple TEST. There ARE numbers and other symbols 1&2&3...........输出样例:
e 7
#include <cstdio>#include <cstring>const int maxn=1005;char s[maxn];int Hash[30]={0};int main(){ gets(s); int len=strlen(s); for(int i=0;i<len;i++){ if(s[i]>='a'&&s[i]<='z') Hash[s[i]-'a']++; else if(s[i]>='A'&&s[i]<='Z') Hash[s[i]-'A']++; } int k=0; for(int i=0;i<26;i++){ if(Hash[i]>Hash[k]){ k=i; } } printf("%c %d",'a'+k,Hash[k]); return 0;}
阅读全文
0 0
- PAT (Basic Level) Practise (中文)1042. 字符统计(20)
- PAT (Basic Level) Practise (中文) 1042. 字符统计(20)
- PAT (Basic Level) Practise (中文)1042. 字符统计(20)
- PAT (Basic Level) Practise (中文)1042. 字符统计(20) C语言
- PAT (Basic Level) Practise (中文)1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文)-1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文)1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文) 1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文)1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文)1038. 统计同成绩学生(20)
- PAT (Basic Level) Practise (中文) 1038. 统计同成绩学生(20)
- PAT (Basic Level) Practise (中文)1038. 统计同成绩学生(20)
- PAT BASIC LEVEL 1042. 字符统计(20)
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)--1001
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)1001
- 模为奇素数的原根求解
- js判断切换输出文本
- linux环境下对mysql数据库的操作
- ORM的概念, ORM到底是什么
- windows cmd命令笔记
- PAT (Basic Level) Practise (中文)1042. 字符统计(20)
- Linux相关知识总结
- jsp页面提示The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path解决方法
- 算法导论16.2-1
- Idea添加JQuery库-解决jsp页面使用jQuery方法时显示Unresolved function or method
- Java提高篇——通过分析 JDK 源代码研究 Hash 存储机制
- Git详解
- FCC算法:十、猴子吃香蕉, 分割数组--Chunky Monkey
- map&set