{
  "question_id": 702202,
  "question_title": "结合两个字符串",
  "question_content": "写一个结合两个字符串的方法，从第一个字符串中取出一个字符，然后从第二个字符串中取出一个字符，以此类推。一旦一个字符串没有字符，它就应该继续使用另一个字符串\n输入：两个字符串，如s1=\"day\"和s2=\"time\"\n输出：一个结果字符串，对于上面的输入情况，它将是“dtaiyme”。",
  "difficulty": "困难",
  "answer_id": 592511,
  "answer_content": "#include<iostream>\n#include<string>\nusing namespace std;\nstring StrCon(const string& a, const string& b)\n{\n\tstring c;\n\tint n = a.size(), m = b.size();\n\tif (0 == n)\treturn a;\n\tif (0 == m) return b;\n\tint i, j;\n\tfor (i = 0, j = 0; i < n && j < m; ++i, ++j)\n\t{\n\t\tc += a[i];\n\t\tc += b[i];\n\t}\n\twhile (i < n)\n\t\tc += a[i++];\n\twhile (j < m)\n\t\tc += b[j++];\n\treturn c;\n}\nint main()\n{\n\tstring s = \"day\", t = \"time\";\n\tcout << StrCon(s, t) << endl;\n\tsystem(\"pause\");\n\treturn 0;\n}\n\n```\n \n```\n\n",
  "tag_name": "c++",
  "cpp": "#include <iostream>\n#include <string>\nusing namespace std;\nstring StrCon(const string& a, const string& b)\n{\n\tstring c;\n\tint n = a.size(), m = b.size();\n\tif (0 == n)\treturn a;\n\tif (0 == m) return b;\n\tint i, j;\n\tfor (i = 0, j = 0; i < n && j < m; ++i, ++j)\n\t{\n\t\tc += a[i];\n\t\tc += b[i];\n\t}\n\twhile (i < n)\n\t\tc += a[i++];\n\twhile (j < m)\n\t\tc += b[j++];\n\treturn c;\n}\nint main()\n{\n\tstring s = \"day\", t = \"time\";\n\tcout << StrCon(s, t) << endl;\n\tsystem(\"pause\");\n\treturn 0;\n}",
  "topic_link": "https://bbs.csdn.net/topics/600469844",
  "status": 1,
  "keywords": "算法高阶,字符串匹配,算法问题选编,利用有限自动机进行字符串匹配",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/26.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "qq_29910115"
}