{"id":207,"date":"2012-05-17T12:47:48","date_gmt":"2012-05-17T04:47:48","guid":{"rendered":"http:\/\/wangkaixuan.tech\/?p=207"},"modified":"2020-06-04T12:48:29","modified_gmt":"2020-06-04T04:48:29","slug":"%e5%90%88%e5%b9%b6%e6%8e%92%e5%ba%8f","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=207","title":{"rendered":"\u5408\u5e76\u6392\u5e8f"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\/\/\u5408\u5e76\u6392\u5e8f \n#include&lt;iostream>\n#include&lt;cmath>\nusing namespace std;\n \nint num&#91;100];\n \nvoid print(int num&#91;],int len)\n{\n\tfor(int i=0;i&lt;len;i++)\n\t{\n\t\t\tcout&lt;&lt;num&#91;i]&lt;&lt;\" \";\n\t}\t\n\tcout&lt;&lt;endl;\n}\n \nvoid merge(int num&#91;],int beg,int mid,int end)\n{\n\tint temp&#91;100];\n\tint t=beg;\n\tint i=beg,j=mid+1;\n\twhile(i&lt;=mid&amp;&amp;j&lt;=end)\n\t{\n\t\tif(num&#91;i]&lt;num&#91;j])\t\n\t\t\ttemp&#91;t++]=num&#91;i++];\n\t\telse\n\t\t\ttemp&#91;t++]=num&#91;j++];\n\t}\n\twhile(i&lt;=mid)\n\t\ttemp&#91;t++]=num&#91;i++];\n\twhile(j&lt;=end)\n\t\ttemp&#91;t++]=num&#91;j++];\n\tfor(int i=beg;i&lt;=end;i++)\n\t\tnum&#91;i]=temp&#91;i];\n}\n \nvoid mergeSort(int num&#91;],int beg,int end)\n{\n\tif(beg==end)\n\t\treturn;\n\tint mid=(beg+end)\/2;\n\tmergeSort(num,beg,mid);\n\tmergeSort(num,mid+1,end);\n\tmerge(num,beg,mid,end);\t\n}\n \n \nint main()\n{\n        int len;\n        while(cin>>len)\n        {\n              for(int i=0;i&lt;len;i++)\n              cin>>num&#91;i];\n              mergeSort(num,0,len-1);\n              print(num,len);\n        }\n        return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-207","post","type-post","status-publish","format-standard","hentry","category-06-02-"],"_links":{"self":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=207"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/207\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}