while((c=tolower(getchar()))!=’\n’)
#include<stdio.h>
int main(){
char c;
int record[128] = {0};
while( (c = getchar()) != '\n'){
if( c>= 65 && c <= 90){
c += 32; //while((c=tolower(getchar()))!='\n')
}
record[c]++;
}
int maxi = 0, max = 0;
for(int i = 97; i < 123; i++){
if(record[i] > max){
max = record[i];
maxi = i;
}
}
printf("%c %d", (char)maxi, max);
return 0;
}
本文介绍了一个C语言程序,用于统计并找出输入字符串中出现次数最多的英文字母。程序使用了字符数组来记录每个字符的出现次数,并通过遍历和比较找到出现次数最多的字符。
701

被折叠的 条评论
为什么被折叠?



