#include <stdio.h> #include<malloc.h> #include<string.h> int main() { char str[20], rec[26] = {0}; char len, i, j, min; scanf("%s", str); len = strlen(str); min = len + 1; for (i = 0; i < len; i++) { rec[str[i] - 'a']++; //计数各字符出现次数 } //最少字符 for (i = 0; i < 26; i++) { if (rec[i] && rec[i] < min) min = rec[i]; } //删除最少字符 for (i = 0, j = 0; i < len; i++) { if (rec[str[i] - 'a'] > min ) str[j++] = str[i]; } str[j] = 0; printf("%s", str); }