solution.json 1.8 KB
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
{
  "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 <iostream>\n#include <string>\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"
}