{ "type": "code_options", "author": "csdn.net", "source": "solution.md", "exercise_id": "0f46f7cc63a64195a69ecf894966c670", "keywords": "算法高阶,字符串匹配,算法问题选编,利用有限自动机进行字符串匹配", "title": "字符串匹配", "desc": [ { "content": "\n

输入两个字符串s1和s2,在s1中查找s2对应的字符串是否存在,若存在则输出它第一次出现的位置;若不存在,则输出“没有找到该字符串”。

", "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\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)<