自己写的。C语言。题解 | #字符统计#
字符统计
https://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0
#include<stdio.h> int main() { char line[1001]; int count[128] = {0}; int i = 0, max; scanf("%s", line); while (line[i] != '\0') { count[line[i]]++; i++; } while (1) { max = 0; for (i = 0; i < 128; i++) { if (count[i] > max) { max = count[i]; } } if (max == 0) { break; } for (i = 0; i < 128; i++) { if (count[i] == max) { printf("%c", i); count[i] = 0; i = 128; } } } return 0; }