统计字符数

···

include

include

include

using namespace std;

int main()
{
int cases, sum[26], i, max;
char str[1001];

cin >> cases;
while (cases > 0) {
    cin >> str;
    for (i = 0; i < 26; i++) {//每次都赋出现次数初值0
        sum[i] = 0;
    }
    for (i = 0; i < strlen(str); i++) {//记各个数字出现次数
        sum[str[i] - 'a']++;
    }
        max = 0;        
        for (i = 0; i < 26; i++) {
            if (sum[i] > sum[max])max = i;//找出最大的
        }
        cout <

}
···

你可能感兴趣的:(统计字符数)