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. CentOS安装rar及用法

    1.下载安装rar wget http://www.rarsoft.com/rar/rarlinux-x64-5.4.b3.tar.gztar -zxvf rarlinux-x64-.tar.gz - ...

  2. H-JATG:NAND_FLASH的参数设置

    JATG:NAND_FLASH     不同的cpu同一款flash:         相同的cpu不同的flash:     相同的cpu不同厂家的的flash:

  3. (转)Free函数的参数一定要是malloc返回的那个指针

    Free函数的参数一定要是malloc返回的那个指针   之前认为只要free的参数在malloc分配的区域之内就可以了, 现在发现不对的.在嵌入式里分配堆都是按照块来的,只要在这个块内系统就能识别, ...

  4. 【集训笔记】计算几何【HDOJ2036【HDOJ1086【HDOJ1115【HDOJ1147【HDOJ1392 【ZOJ2976

    改革春风吹满地 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted ...

  5. Spring IOC三种注入方式(接口注入、setter注入、构造器注入)(摘抄)

    IOC ,全称 (Inverse Of Control) ,中文意思为:控制反转, Spring 框架的核心基于控制反转原理. 什么是控制反转?控制反转是一种将组件依赖关系的创建和管理置于程序外部的技 ...

  6. Qt学习:线程间共享数据(使用信号槽传递数据,必须提前使用qRegisterMetaType来注册参数的类型)

    Qt线程间共享数据主要有两种方式: 使用共享内存.即使用一个两个线程都能够共享的变量(如全局变量),这样两个线程都能够访问和修改该变量,从而达到共享数据的目的: 使用singal/slot机制,把数据 ...

  7. JavaScript:获取系统当前时间,构造格式化的字符串

    var getNowFormatDate = function() {    var date = new Date();    var seperator1 = "-";    ...

  8. android 应用静默自启动的解决方法

    一个apk完全的自动静默启动目前不能实现,所以就用到了Activity的一个方法activity.moveTaskToBack(boolean),这个方法就是可以退出应用到后台而不是finish()退 ...

  9. Winform ErrorProvider控件使用

    要实现的功能:判断第一个文本框中输入的是不是字符 “a”. 最终效果: *当输入的不是a,控件旁会显示错误图标.当输入的是a,则错误图标会消失. 首先添加ErrorProvider控件. 代码: pr ...

  10. AOP编程

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...