{"id":301,"date":"2021-11-08T21:52:16","date_gmt":"2021-11-08T13:52:16","guid":{"rendered":"https:\/\/mzdyl.xyz\/?p=301"},"modified":"2022-03-19T00:25:23","modified_gmt":"2022-03-18T16:25:23","slug":"%e4%bd%9c%e4%b8%9a10-1","status":"publish","type":"post","link":"https:\/\/mzdyl.xyz\/index.php\/2021\/11\/08\/%e4%bd%9c%e4%b8%9a10-1\/","title":{"rendered":"\u4f5c\u4e1a10-1"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#include &lt;bits\/stdc++.h>\r\n\/\/1. \u7f16\u5199\u51fd\u6570\uff0c\u53d6\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u5b50\u4e32\u3002\r\nusing namespace std;\r\n\r\nstring GetSubstring(string s,int a,int b)\r\n{\r\n\t\tstring ans(s,a,b);\r\n\t\treturn ans;\r\n}\r\n\r\nint main()\r\n{\r\n\t\tstring s;\r\n\t\tint a,b;\r\n\t\tcout &lt;&lt; \"Input string\"&lt;&lt;endl;\/\/\u8f93\u5165\u5b57\u7b26\u4e32\r\n\t\tcin >> s;\r\n\t\tcout &lt;&lt; \"Enter the substring subscript range to be obtained (the following table starts from 0)\"&lt;&lt;endl;\/\/\u8f93\u5165\u8981\u83b7\u53d6\u7684\u5b50\u4e32\u4e0b\u6807\u8303\u56f4(\u4e0b\u8868\u4ece0\u5f00\u59cb)\r\n\t\tcin >> a >> b;\r\n\t\tstring ans = GetSubstring(s,a,b);\r\n\t\tcout &lt;&lt; ans;\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;bits\/stdc++.h>\r\nusing namespace std;\r\n\r\n\/\/2. \u7f16\u5199\u51fd\u6570\uff0c\u628a\u4e00\u4e2a\u5b57\u7b26\u4e32\u63d2\u5165\u5230\u53e6\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e2d\u6307\u5b9a\u4f4d\u7f6e\u3002\r\n\r\nvoid AppSubstring(char *&amp;s_1,int a,char *s_2)\r\n{\r\n\t\tchar *ans;\r\n\r\n\t\tint len = sizeof(s_1) + sizeof(s_2);\r\n\t\tint llen = 0;\r\n\t\tans = new char&#91;len];\r\n\t\tfor(int i=0; i&lt;=len; i++)\r\n\t\t{\r\n\t\t\t\tif(i==a+1)\r\n\t\t\t\t\t\tfor(unsigned int ii=0; ii&lt;strlen(s_2); ii++)\r\n\t\t\t\t\t\t\t\tans&#91;llen++] = s_2&#91;ii];\r\n\t\t\t\tans&#91;llen++]=s_1&#91;i];\r\n\t\t}\r\n\t\tdelete s_1;\r\n\t\ts_1 = ans;\r\n}\r\n\r\nint main()\r\n{\r\n\t\tchar *s_1=\"abcfgh\";\r\n\t\tchar *s_2=\"de\";\r\n\t\tint a = 2;\r\n\t\tAppSubstring(s_1,a,s_2);\r\n\t\tcout &lt;&lt; s_1;\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;bits\/stdc++.h>\r\nusing namespace std;\r\n\r\n\/\/3. \u7f16\u5199\u51fd\u6570\uff0c\u6c42\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e2d\u4e0d\u91cd\u590d\u5b57\u7b26\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff0c\u5982\u5b57\u7b26\u4e32\u201cdasasew\u201d\u7684\u4e0d\u91cd\u590d\u5b57\u7b26\u4e32\u4e3a\u201cdasew\u201d\u3002\uff08\u9009\u505a\uff09\r\n\r\nstring NotRepeatingSubstring(string s)\r\n{\r\n\t\tbool PdAscii&#91;256];\r\n\t\tmemset(PdAscii,0,sizeof(PdAscii));\r\n\t\tchar ans&#91;256];\r\n\t\tint n=0;\r\n\t\tfor(int i=0; i&lt;=s.length(); i++)\r\n\t\t{\r\n\t\t\t\tif(!PdAscii&#91;s&#91;i]])\r\n\t\t\t\t{\r\n\t\t\t\t\t\tPdAscii&#91;s&#91;i]]=1;\r\n\t\t\t\t\t\tans&#91;n++]=s&#91;i];\r\n\t\t\t\t}\r\n\t\t}\r\n\t\treturn ans;\r\n}\r\n\r\nint main()\r\n{\r\n\t\tstring s;\r\n\t\tcin >> s;\r\n\t\tstring ans = NotRepeatingSubstring(s);\r\n\t\tcout &lt;&lt; ans;\r\n}\r\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-301","post","type-post","status-publish","format-standard","hentry","category-c_plus"],"_links":{"self":[{"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/posts\/301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=301"}],"version-history":[{"count":3,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/posts\/301\/revisions"}],"predecessor-version":[{"id":513,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/posts\/301\/revisions\/513"}],"wp:attachment":[{"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mzdyl.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}