{
  "question_id": 7450354,
  "question_title": "字符串匹配",
  "question_content": "<p>输入两个字符串s1和s2&#xff0c;在s1中查找s2对应的字符串是否存在&#xff0c;若存在则输出它第一次出现的位置&#xff1b;若不存在&#xff0c;则输出“没有找到该字符串”。</p>",
  "difficulty": "简单",
  "answer_id": 53431020,
  "answer_content": "<pre>\n<code class=\"language-cpp\">#include &lt;string&gt;\n#include &lt;iostream&gt;\n\nusing namespace std;\n\nint main()\n{\n\tstring s1, s2;\n\tcout &lt;&lt; &#34;请输入第一个字符串&#xff1a;&#34;;\n\tcin &gt;&gt; s1;\n\tcout &lt;&lt; &#34;请输入第二个字符串&#xff1a;&#34;;\n\tcin &gt;&gt; s2;\n\tif (s1.find(s2) !&#61; -1)\n\t\tcout &lt;&lt; s1.find(s2)&lt;&lt;endl;\n\telse\n\t\tcout &lt;&lt; &#34;没有找到该字符串&#34;&lt;&lt;endl;\n\tsystem(&#34;pause&#34;);\n    return 0;\n}</code></pre>\n\n<p style=\"text-align:center\"><img alt=\"\" src=\"https://img-ask.csdnimg.cn/upload/1623807958048.png\" /></p>\n\n<p> </p>\n",
  "tag_name": "c++",
  "cpp": "#include <string>\n#include <iostream>\nusing namespace std;\nint main()\n{\n\tstring s1, s2;\n\tcout << \"请输入第一个字符串：\";\n\tcin >> s1;\n\tcout << \"请输入第二个字符串：\";\n\tcin >> s2;\n\tif (s1.find(s2) != -1)\n\t\tcout << s1.find(s2)<<endl;\n\telse\n\t\tcout << \"没有找到该字符串\"<<endl;\n\tsystem(\"pause\");\n\treturn 0;\n}",
  "topic_link": "https://bbs.csdn.net/topics/600470271",
  "status": 1,
  "keywords": "算法高阶,字符串匹配,算法问题选编,利用有限自动机进行字符串匹配",
  "license": "csdn.net",
  "notebook": {
    "cpp": "https://codechina.csdn.net/csdn/csdn-daily-code/-/jupyter/master/data/notebook/answer/ipynb/cpp/90.ipynb?type=file"
  },
  "notebook_enable": 1,
  "author": "xigua123321"
}