#include <iostream> #include <set> using namespace std; int main() { char str[100] = { 0 }; cin.getline(str, sizeof(str)); // 读取整行输入 set<char> st; for (int i = 0; str[i] != '\0'; ++i) { // 遍历输入字符串 if (str[i] != ' ') { // 如果不是空格,就插入到 set 容器中去重 st.insert(str[i]); } } for (auto c : st) { // 使用 range-based for 循环遍历 set 容器中的元素 cout << c; } cout << endl; return 0; }