博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[解题报告]499 - What's The Frequency, Kenneth?
阅读量:6274 次
发布时间:2019-06-22

本文共 2416 字,大约阅读时间需要 8 分钟。

 What's The Frequency, Kenneth? 

 

#include 
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 makedbx, andRCS, 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 editor more powerful than words. Further, for each instantiation vi hitherto, the Engineer responsible shalt perform Penance. And lo, the Penance wilt be painful; there will be much wailing and gnushingof teeth. The Engineer will 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 alphabetical list of lower case letters.

 

Sample Input

 

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

 

Sample Output

 

e 6al 7a 3Hlo 2 学会使用memset函数

void *memset(void *s,int ch,size_t n);

函数解释:将 s 中前 n 个字节用 ch 替换并返回 s 。
memset:作用是在一段内存块中填充某个给定的值,它是对较大的结构体或数组进行清零操作的一种最快方法。

 

如把一个char a[20]清零,一定是 memset(a,0,20);

(地址,要赋予的值,连续几个字节)

 

#include 
#include
#define MAX(x,y) (x>y?x:y)char str[1234567];int num[256];int main(){ int i; int max; while(gets(str)) { if(str[0]=='\0')continue; memset(num,0,sizeof(num)); for(i=0;str[i]!='\0';++i)++num[(int)str[i]]; max = 0; for(i='A';i<='Z';++i)max = MAX(max,num[i]); for(i='a';i<='z';++i)max = MAX(max,num[i]); for(i='A';i<='Z';++i)if(num[i]==max)putchar(i); for(i='a';i<='z';++i)if(num[i]==max)putchar(i); printf(" %d\n",max); } return 0;}

 

转载于:https://www.cnblogs.com/TheLaughingMan/archive/2013/02/24/2924688.html

你可能感兴趣的文章
zabbix监控进程与端口
查看>>
Libvirsh 问题:GLib-WARNING **: gmem.c:483: custom memory allocation vtable not supported
查看>>
COALESCE函数
查看>>
Ext.require callback 不执行
查看>>
面试题:连续子数组的最大和
查看>>
书生教你cocos2d-x-入门篇(一)
查看>>
Linux—yum环境的三种搭建方法
查看>>
Windows Server 2016-命令行批量导出AD用户信息
查看>>
Spring Security 过滤流程
查看>>
Vue transition源码浅析
查看>>
如何提升团队的研发效率?来听听阿里研发专家是怎么说的
查看>>
Django-关于manage.py migrate无效的问题
查看>>
eclipse maven创建web工程2.0转3.0
查看>>
FTP 服务器上传文件 553 Could not create file
查看>>
this的用法
查看>>
windows下安装redis
查看>>
CentOS7 yum 安装git
查看>>
启动日志中频繁出现以下信息
查看>>
httpd – 对Apache的DFOREGROUND感到困惑
查看>>
分布式锁的一点理解
查看>>