填空题
下列给定程序中,函数fun的功能是:找出形参s所指字符串中出现频率最高的字母(不区分大小写),并统计出其出现的次数。
例如,形参s所指的字符串为:abcAbsmaxless,程序执行后的输出结果为:
leffer"a":3times
leffer"s":3times
请在程序的下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<string.h>
#include<ctype.h>
void fun(char*s)
{int k[26]={0},n,i,max=0;char ch;
while(*s)
{if(isalpha(*s))
{
/********found********/
ch=tolower(
1);
n=ch-"a";
/********found********/
k[n]+=
2;
}
s++;
/********found********/
if(max<k[n])max=
3;
}
printf("/nAfter count:/n");
for(i=0;i<26;i++)
if(k[i]==max)
printf("/nletter"%c":%d times/n",i+"a",k[i]);
}
main()
{char s[81];
printf("/nEnter a string:/n/n");
gets(s);fun(s);}