intmain() { cin.tie(nullptr)->sync_with_stdio(false); string s; for (; cin >> s; memset(cnt, 0, sizeof cnt)) { for (int i = 0, n = s.size(); i < n; i++) { cnt[s[i]]++; } int minval = 0x3f3f3f3f; for (int i = 97; i < 123; i++) { if (cnt[i]) minval = min(minval, cnt[i]); } string res; for (int i = 0, n = s.size(); i < n; i++) { if (cnt[s[i]] != minval) res += s[i]; } cout << res << endl; } return0; }
publicclassMain{ privatestaticfinalint N = 128; privatestaticint[] cnt = newint[N]; publicstaticvoidmain(String[] args){ Scanner in = new Scanner(System.in); for (; in.hasNext(); Arrays.fill(cnt, 0x0)) { String s = in.next(); for (int i = 0, n = s.length(); i < n; i++) { char c = s.charAt(i); cnt[c]++; // 类型自动提升 } int mn = 0x3f3f3f3f; for (int i = 97; i < 123; i++) { if (cnt[i] != 0) mn = Math.min(mn, cnt[i]); } StringBuilder res = new StringBuilder(); for (int i = 0, n = s.length(); i < n; i++) { if (cnt[s.charAt(i)] != mn) res.append(s.charAt(i)); } System.out.println(res.toString()); } } }