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. codeblock快捷键

    一款开源的C/C++ IDE(集成开发环境),基于wxWidgets GUI体系,跨平台支持. 从别处粘贴的,方便以后看,啦啦啦…… 编辑器 快捷键 功能 Ctrl+Z 恢复上一次操作 Ctrl+Sh ...

  2. BZOJ 1455: 罗马游戏( 配对堆 + 并查集 )

    可并堆水题 --------------------------------------------------------- #include<bits/stdc++.h>   usin ...

  3. 触发器应用 trigger

    首先有一张表: create table T_SALARY ( name VARCHAR2(20), age NUMBER(2), salary NUMBER(5) ); insert into t_ ...

  4. html向servlet传乱码解决办法

    html 设置为utf-8格式 <meta http-equiv="content-type" content="text/html;charset=UTF-8&q ...

  5. 基于Sql Server 2008的分布式数据库的实践(一)

    原文 基于Sql Server 2008的分布式数据库的实践(一) 配置Sql Server 2008(Win7) 1.打开SQL server2012,使用windows身份登录 2.登录后,右键选 ...

  6. hbase安装配置(整合到hadoop)

    hbase安装配置(整合到hadoop) 如果想详细了解hbase的安装:http://abloz.com/hbase/book.html 和官网http://hbase.apache.org/ 1. ...

  7. cmake 学习笔记(一)

    最大的Qt4程序群(KDE4)采用cmake作为构建系统 Qt4的python绑定(pyside)采用了cmake作为构建系统 开源的图像处理库 opencv 采用cmake 作为构建系统 ... 看 ...

  8. sequence2(高精度dp)

    sequence2 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total ...

  9. 疯牛-- Aggressive cows (二分)

    疯牛 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 农夫 John 建造了一座很长的畜栏,它包括N (2 <= N <= 100,000)个隔间,这些小 ...

  10. Activity的创建和使用

    Activity: 1:创建一个类继承Activity或者它的子类 public class MainActivity extends Activity { @Override protected v ...