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. Ubuntu15.04上为火狐浏览器安装Adobe Flash Player插件

    前言:最新版的ubuntu好像没有flashplayer,而且更新源也无法更新成功,找些资料终于发现 这个需要自己手动配置.由于flashplayer无法安装,导致视频,百度上传等功能都无法使用: 安 ...

  2. qml+opencv(二),实现人脸检测

    http://blog.csdn.net/zhx6044/article/details/45048765

  3. android getDecorView()的作用

    decorView是window中的最顶层view,可以从window中通过getDecorView获取到decorView.通过decorView获取到程序显示的区域,包括标题栏,但不包括状态栏.间 ...

  4. 一个load飙高的过程分析,非常有价值(转)

    关于us高和sy高的问题分析: 当us值过高时,表示运行的应用消耗大量的CPU.java应用造成us高的原因主要是线程一直处于可运行(Runnable)状态,通常这些线程在执行无阻塞.循环.正则或纯粹 ...

  5. GlusterFS常用命令

    1.启动/关闭/查看glusterd服务 # /etc/init.d/glusterd start # /etc/init.d/glusterd stop # /etc/init.d/glusterd ...

  6. 在把数据库文件放在raw中,在应用程序中如何打开

    1.DbManager代码 package com.zyh.zyhimportdatabase; import java.io.File; import java.io.FileOutputStrea ...

  7. ASP.NET页面之间传值

    介绍: 在网页应用程序的开发中,页面之间的传值应该是最常见的问题了. 在这篇文章里,azamsharp 将为我们介绍一些ASP.NET页面传值的方式.本文所举的例子非常简单,仅仅包含了一个文本框和几个 ...

  8. java--进步学习IO

    import java.io.*; public class Demo1 { public static void main(String []args) throws Exception{ File ...

  9. [Boost]boost的时间和日期处理-(1)日期的操作

    <开篇> Boost.DateTime库提供了时间日期相关的计算.格式化.转换.输入输出等等功能,为C++的编程提供了便利.不过它有如下特点: 1. Boost.DateTime 只支持1 ...

  10. struts2之高危远程代码执行漏洞,可造成服务器被入侵,下载最新版本进行修复

          Struts2 被发现存在新的高危远程代码执行漏洞,可造成服务器被入侵,只要是Struts2版本 低于 2.3.14.3 全部存在此漏洞.目前官方已经发布了最新的版本进行修复.请将stru ...