What's The Frequency, Kenneth? 
#include <stdio.h>

main()
{
int i;
char *suffix[]= { "st", "nd", "rd" };
char *item[]= { "Unix" , "cat", "sed", "awk", "grep", "ed", "vi"}; printf("In the beginning, there was nothing.\n");
for (i= 0; i < 7; i++)
printf("And on the %d%s day, God created %s. And it was good.\n",
i + 1, (i < 3) ? suffix[i] : "th", item[i]);
}

But then God saw that vi led people into temptation. Instead of choosing the righteous ways of make,dbx, and RCS, people used long command lines, printf(), and tape backups.

So God decreed, ``I see that Engineers have thus defiled my vi. And so, I shall create emacs, an editormore powerful than words. Further, for each instantiation vi hitherto, the Engineer responsible shalt performPenance. And lo, the Penance wilt be painful; there will be much wailing and gnushingof teeth. The Engineerwill read many lines of text. For each line of text, the Engineer must tell me which letters occur the most frequently.''

``I charge you all with My Golden Rule: 'Friends shalt not let friends use vi'.''

Input and Output

Each line of output should contain a list of letters that all occured with the highest frequency in the corresponding input line, followed by the frequency.

The list of letters should be an alphabetical list of upper case letters followed by an alphabeticallist of lower case letters.

Sample Input

When riding your bicycle backwards down a one-way street, if the
wheel falls of a canoe, how many ball bearings does it take to fill
up a water buffalo?
Hello Howard.

Sample Output

e 6
al 7
a 3
Hlo 2
#include<stdio.h>
#include<string.h>
int max(int *a)
{
int i,max=0;
for(i=0;i<52;i++)
if(a[i]>max) max=a[i];
return max;
}
int main(void)
{
char a[100]={0}; while((gets(a))!=NULL)
{
int count[52]={0},i;
for(i=0;i<strlen(a);i++)
{
if(a[i]<='z'&&a[i]>='a')
count[a[i]-'a'+26]++;
else if(a[i]<='Z'&&a[i]>='A')
count[a[i]-'A']++;
}
for(i=0;i<52;i++)
if(count[i]==max(count))
{
if(i<26)
putchar(i+'A');
else
putchar(i+'a'-26);
}
printf(" %d\n",max(count));
}
return 0;
}

499 - What's The Frequency, Kenneth?的更多相关文章

  1. [LeetCode] Sort Characters By Frequency 根据字符出现频率排序

    Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: ...

  2. [LeetCode] Word Frequency 单词频率

    Write a bash script to calculate the frequency of each word in a text file words.txt. For simplicity ...

  3. nginx 499 状态码优化

    在grafana界面中发现不少499的状态码,在网上了解到出现499的原因大体都是说服务端处理时间过长,客户端主动关闭了连接.   既然原因可能是服务端处理时间太长了,看一下upstream_resp ...

  4. 451. Sort Characters By Frequency

    题目: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Inp ...

  5. Sort Characters By Frequency

    Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: ...

  6. CPU frequency and voltage scaling code in the Linux(TM) kernel

    CPU frequency and voltage scaling code in the Linux(TM) kernel CPU frequency scaling Using CPUfreq G ...

  7. Nginx状态码499

    1.问题描述 140.207.202.187 - - [18/May/2016:10:30:58 +0800] "POST/v3/violations HTTP/1.1" 499 ...

  8. High Frequency Trading (整理中...)

    什么是高频交易系统 1 交易指令完全是由电脑发送,对市场数据的响应延时在微秒级2 系统有专用的软硬件组成,研发时需要大量的计算机专家级的工作3 系统的硬件需要放在离交易所主机很近的位置,所谓co-lo ...

  9. Nginx_HTTP 499 状态码 nginx下 499错误

    日志记录中HTTP状态码出现499错误有多种情况,我遇到的一种情况是nginx反代到一个永远打不开的后端,就这样了,日志状态记录是499.发送字节数是0. 老是有用户反映网站系统时好时坏,因为线上的产 ...

随机推荐

  1. iOS Development: Proper Use of initWithNibName:bundle: Affects UITableViewController

    Address:http://www.outofcore.com/2011/07/ios-development-proper-use-of-initwithnibnamebundle-affects ...

  2. [Swust OJ 179]--火柴棍(找规律)

    题目链接:http://acm.swust.edu.cn/problem/0179/ Time limit(ms): 1000 Memory limit(kb): 65535   Descriptio ...

  3. Java面试题集(1-50)

    下面的内容是对网上原有的面试题集及答案进行了全面修订之后的内容(原来的题目有很多重复无用的题以及错误的答案),参照了JDK最新版本,删除了重复题目以及EJB2.x等无用内容,补充最新面试题.知识点巩固 ...

  4. iOS 常用开源代码整理

    本文章不定期整理. 1.AFNetworking AFNetworking 采用 NSURLConnection + NSOperation, 主要方便与服务端 API 进行数据交换, 操作简单, 功 ...

  5. jquery删除动态增加的li

    <script type="text/jscript"> //楼主帮你修改调整了下 $(document).ready(function () { $('.zuo li ...

  6. Java--日期的使用

    Date 类: 最基础的日期时间类,返回一个相对日期的毫秒数.精确到毫秒,但不支持日期的国际化和分时区显示. Calender类: 相对于Date更加强大的时间类,是抽象类,提供了常规的日期修改功能和 ...

  7. Google Map Android api V2 中使用MapView遇到CameraUpdateFactory is not initialized!的解决办法

    先说一下 Map V2 API Key 的问题吧: 在打包APP时需要自己生成一个XXX.keystore 用这个密室库生成的SHA1去申请的key 作为AndroidManifest.xml 中的K ...

  8. SVProgressHUD的使用

    GitHub:https://github.com/samvermette/SVProgressHUD SVProgressHUD和MBProgressHUD效果差点儿相同,只是不须要使用协议,同一时 ...

  9. PHP - 四级单词lrc文件解析为txt

    原始文件: 转换后文件: php代码: 首先根据需要更改文件路径. 转换后存放的文件要事先创建,为txt文件. 核心代码:正则表达式替换: <?php header('Content-type: ...

  10. 输入输出函数 I/O函数之perror()

    perror()函数的函数原型 void perror(char const *message); 它会将message信息输出出来,后面再加上错误原因字符串. 下面是来自百度百科的实例: #incl ...