{ "type": "code_options", "author": "csdn.net", "source": "solution.md", "exercise_id": "dfcde76c90054b1eb7b5ed66d00acb4a", "keywords": "算法,字符串", "title": "找出string中只出现过一次的字符", "desc": [ { "content": "\n找出string中只出现过一次的字符\n例如\"abcdef abcd\"中需要得到ef", "language": "markdown" } ], "answer": [ { "content": "", "language": "cpp" } ], "prepared": [ [ { "content": "", "language": "cpp" } ], [ { "content": "", "language": "cpp" } ], [ { "content": "", "language": "cpp" } ] ], "template": { "content": "#include \n#include \nusing namespace std;\nint main()\n{\n    string temp = \"\";\n    cout << \"请输入字符串:\";\n    cin >> temp;\n    string str = \"\";        \n    string str1 = \"\";        \n    for (int i = 0; i < temp.length(); i++)\n    {\n        string tempSub = temp.substr(i, 1);    \n        int b = temp.rfind(tempSub);                \n        if (i == b && str1.find(tempSub) == -1)        \n            str +=temp.substr(i, 1);\n        else if (str1.find(tempSub) == -1)\n            str1 += temp.substr(i, 1);\n    }\n    cout << \"只出现一次的字符:\" << str << endl;\n    cout << \"重复出现的字符的字符:\" << str1 << endl;\n    system(\"pause\");\n    return 0;\n}", "language": "cpp" }, "node_id": "dailycode-6d96a821994d46f8a4c62dfe46b82481", "license": "csdn.net", "created_at": 1637894160, "topic_link": "https://bbs.csdn.net/topics/600470278" }