1042 字符统计

来源:互联网 发布:饥荒数据修改易宁 编辑:程序博客网 时间:2024/06/08 14:27
#include<stdio.h>int main(){    char str[1001];    gets(str);    int table[150], max=0;    for(int i=0; i<150; ++i)        table[i]=0;    for(int i=0; str[i]!='\0'; ++i){        if(str[i]>='A' && str[i]<='Z'){            ++table[str[i]+32];            if(table[str[i]+32] > max)                max = table[str[i]+32];        }else if(str[i]>='a' && str[i]<='z'){            ++table[str[i]];            if(table[str[i]] > max)                max = table[str[i]];        }    }    for(int i=97; i<150; ++i){        if(table[i] == max){            printf("%c %d", i, max);            break;        }    }    return 0;}
0 0