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. ssh "openssh-daemon is stopped"操作之伤+sftp访问“-bash: /dev/null: Permission denied”

    1.ssh "openssh-daemon is stopped"操作之伤 原来好好的 sshd服务突然发现  不能重新启动了: [root@bogon rules.d]# ser ...

  2. USACO Milk2 区间合并

    这题WA了四次,后来发现不能用所谓的桶排来写 虽然空间上是可以的,但是存在这样一个问题 比如两组数据[15,20]和[21,30] 在20 和 21这两个时刻之间没有milking,但是用桶排的方法写 ...

  3. Ural 1079 - Maximum

    Consider the sequence of numbers ai, i = 0, 1, 2, …, which satisfies the following requirements: a0  ...

  4. 怎样为ubuntu eclipse 添加 GBK字符集

    以前没有发现,最近把自己的代码靠到同学电脑上运行报错,发现是字符集的问题,一般来说 eclipse默认的是GBK编码,而ubuntu上默认是没有GBK编码的,所以ubuntu eclipse 上自然就 ...

  5. UVA 10340 (13.08.25)

    Problem E All in All Input: standard input Output: standard output Time Limit: 2 seconds Memory Limi ...

  6. Swift编程语言学习11—— 枚举全局变量、局部变量与类型属性

    全局变量和局部变量 计算属性和属性监视器所描写叙述的模式也能够用于全局变量和局部变量,全局变量是在函数.方法.闭包或不论什么类型之外定义的变量,局部变量是在函数.方法或闭包内部定义的变量. 前面章节提 ...

  7. 如何创建C++程序

    下载Microsoft Visual C++ 6.0请点击这里:VC 6.0下载(包括中文版英文版)(支持Win7和XP) 首先,我们要进入Microsoft Visual C++集成开发环境(Int ...

  8. iOS 7 - Auto Layout on iOS Versions prior to 6.0

    链接地址:http://stackoverflow.com/questions/18735847/ios-7-auto-layout-on-ios-versions-prior-to-6-0 Stac ...

  9. [置顶] JNI之java传递数据给c语言

    1.首先创建 DataProvider类: package com.pl.ndkpassdata; public class DataProvider { static{ System.loadLib ...

  10. PAD会取代PC吗

    公司上了新的内部管理系统,上线一片混乱,群里也很热闹,从系统是否应该支持pad谈起 ,有技术大佬说5年内就是pad时代了,pad将完全取代pc.我不知道大佬从何得出这个结论,有和数据支撑.我的观点是, ...