【统计字母出现最多次数不分大小写按字典顺序输出】2022-11-9
缘由C++小菜鸡求帮助,可有偿-编程语言-CSDN问答
void 统计字母出现最多次数不分大小写按字典顺序输出(string str, int n)
{int a[26]{}, x = 0, d = 0;while (x < n){if (str[x] >= 'A'&&str[x] <= 'Z')++a[str[x] - 'A'], ((a[str[x] - 'A'] > d) ? d = a[str[x] - 'A'] : 0);if (str[x] >= 'a'&&str[x] <= 'z')++a[str[x] - 'a'], ((a[str[x] - 'a'] > d) ? d = a[str[x] - 'a'] : 0);++x;}x = 0;while (x++ < 26)if (a[x] == d)cout << (char)('a' + x);cout << endl;
}