自己写的。C语言题解 | #删除字符串中出现次数最少的字符#
删除字符串中出现次数最少的字符
https://www.nowcoder.com/practice/05182d328eb848dda7fdd5e029a56da9
#include<stdio.h> int main() { int letter[26] = {0}; char line[21]; int i = 0, min = 21; scanf("%s", line); while (line[i] != '\0') { letter[line[i] - 'a']++; i++; } for (i = 0; i < 26; i++) { if (letter[i] > 0 && letter[i] < min) { min = letter[i]; } } i = 0; while (line[i] != '\0') { if (letter[line[i] - 'a'] != min) { printf("%c", line[i]); } i++; } return 0; }