{"id":2890,"date":"2022-01-22T11:06:30","date_gmt":"2022-01-22T03:06:30","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=2890"},"modified":"2024-05-05T14:19:26","modified_gmt":"2024-05-05T06:19:26","slug":"%e4%b8%a4%e6%95%b0%e4%b9%8b%e5%92%8c","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=2890","title":{"rendered":"\u4e24\u6570\u4e4b\u548c"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor:pointer\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.iyatt.com\/?p=2890\/#%E9%A2%98%E7%9B%AE\" >\u9898\u76ee<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.iyatt.com\/?p=2890\/#Python3\" >Python3<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.iyatt.com\/?p=2890\/#C\" >C<\/a><\/li><\/ul><\/nav><\/div>\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%A2%98%E7%9B%AE\"><\/span>\u9898\u76ee<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u6574\u6570\u6570\u7ec4 nums&nbsp;\u548c\u4e00\u4e2a\u6574\u6570\u76ee\u6807\u503c target\uff0c\u8bf7\u4f60\u5728\u8be5\u6570\u7ec4\u4e2d\u627e\u51fa \u548c\u4e3a\u76ee\u6807\u503c target&nbsp; \u7684\u90a3&nbsp;\u4e24\u4e2a&nbsp;\u6574\u6570\uff0c\u5e76\u8fd4\u56de\u5b83\u4eec\u7684\u6570\u7ec4\u4e0b\u6807\u3002<\/p>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u5047\u8bbe\u6bcf\u79cd\u8f93\u5165\u53ea\u4f1a\u5bf9\u5e94\u4e00\u4e2a\u7b54\u6848\u3002\u4f46\u662f\uff0c\u6570\u7ec4\u4e2d\u540c\u4e00\u4e2a\u5143\u7d20\u5728\u7b54\u6848\u91cc\u4e0d\u80fd\u91cd\u590d\u51fa\u73b0\u3002<\/p>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u6309\u4efb\u610f\u987a\u5e8f\u8fd4\u56de\u7b54\u6848\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u8f93\u5165\uff1anums = [2,7,11,15], target = 9\n\u8f93\u51fa\uff1a[0,1]\n\u89e3\u91ca\uff1a\u56e0\u4e3a nums[0] + nums[1] == 9 \uff0c\u8fd4\u56de [0, 1] \u3002<\/pre>\n\n\n\n<p>\u6765\u6e90\uff1a\u529b\u6263\uff08LeetCode\uff09<br>\u94fe\u63a5\uff1ahttps:\/\/leetcode-cn.com\/problems\/two-sum<br>\u8457\u4f5c\u6743\u5f52\u9886\u6263\u7f51\u7edc\u6240\u6709\u3002\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u5b98\u65b9\u6388\u6743\uff0c\u975e\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Python3\"><\/span>Python3<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Solution:\n    def twoSum(self, nums: List[int], target: int) -> List[int]:\n        size = len(nums)  # \u8f93\u5165\u6570\u7ec4\u7684\u5927\u5c0f\n        for i in range(size-1):  # \u7b2c\u4e00\u4e2a\u52a0\u6570\u4ece\u6570\u7ec4\u7b2c\u4e00\u4e2a\u5f00\u59cb\uff0c\u5012\u6570\u7b2c\u4e8c\u4e2a\u7ed3\u675f\n            add_num = target - nums[i]\n            if add_num in nums[i+1:]:  # \u7b2c\u4e8c\u4e2a\u52a0\u6570\u4ece\u7b2c\u4e00\u4e2a\u52a0\u6570\u7684\u540e\u4e00\u4f4d\u5f00\u59cb\uff0c\u6700\u540e\u4e00\u4e2a\u7ed3\u675f\n                return [i, (nums[i+1:].index(add_num) + i + 1)]<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"456\" height=\"142\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-48.png\" alt=\"\" class=\"wp-image-2893 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-48.png 456w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-48-300x93.png 300w\" data-sizes=\"(max-width: 456px) 100vw, 456px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 456px; --smush-placeholder-aspect-ratio: 456\/142;\" \/><\/figure>\n\n\n\n<p>\u8fd9\u4e2a\u662f\u66b4\u529b\u679a\u4e3e\uff0c\u4f9d\u6b21\u4e24\u4e2a\u4e24\u4e2a\u5730\u6311\u9009\u770b\u662f\u5426\u6ee1\u8db3\u6761\u4ef6\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"525\" height=\"404\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-49.png\" alt=\"\" class=\"wp-image-2896 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-49.png 525w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-49-300x231.png 300w\" data-sizes=\"(max-width: 525px) 100vw, 525px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 525px; --smush-placeholder-aspect-ratio: 525\/404;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"588\" height=\"190\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/D6A7511F80823F161CE72706FBF2D8A8.jpg\" alt=\"\" class=\"wp-image-2897 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/D6A7511F80823F161CE72706FBF2D8A8.jpg 588w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/D6A7511F80823F161CE72706FBF2D8A8-300x97.jpg 300w\" data-sizes=\"(max-width: 588px) 100vw, 588px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 588px; --smush-placeholder-aspect-ratio: 588\/190;\" \/><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Solution:\n    def twoSum(self, nums: List[int], target: int) -> List[int]:\n        size = len(nums)\n        dict = {}\n\n        for idx, val in enumerate(nums):\n            dict[val] = idx  # \u5c06\u6570\u7ec4\u6bcf\u4e00\u4e2a\u5143\u7d20\u653e\u5165\u5b57\u5178\uff0c\u5143\u7d20\u503c\u5bf9\u5e94\u4e0b\u6807\n\n        for idx, val in enumerate(nums):\n            add_index = dict.get(target - val)  # \u6c42\u51fa\u53e6\u5916\u4e00\u4e2a\u52a0\u6570\uff0c\u5e76\u641c\u7d22\u5b57\u5178\u4e2d\u662f\u5426\u5b58\u5728\uff0c\u5b58\u5728\u4e14\u4e0d\u662f\u91cd\u590d\u7b2c\u4e00\u4e2a\u5c31\u627e\u51fa\u6765\u4e86\n            if add_index is not None and idx != add_index:\n                return [idx,add_index]<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"894\" height=\"658\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-50.png\" alt=\"\" class=\"wp-image-2898 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-50.png 894w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-50-300x221.png 300w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-50-768x565.png 768w\" data-sizes=\"(max-width: 894px) 100vw, 894px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 894px; --smush-placeholder-aspect-ratio: 894\/658;\" \/><\/figure>\n\n\n\n<p>\u76f8\u6bd4\u4e8e\u524d\u9762\u66b4\u529b\u7684\u89e3\u6cd5\uff0c\u65f6\u95f4\u964d\u4e86\u4e00\u4e2a\u6570\u91cf\u7ea7\uff0c\u6211\u63d0\u4ea4\u51e0\u6b21\uff0c\u65f6\u95f4\u6ce2\u52a8\u4e00\u70b9\uff0c\u663e\u793a\u7684\u51fb\u8d25\u7528\u6237\u767e\u5206\u6bd4\u5374\u6709\u5341\u51e0\u4e8c\u5341\u7684\u8df3\u52a8\uff0c\u8fd9\u70b9\u65f6\u95f4\u53d8\u5316\u662f\u968f\u673a\u4e0d\u53ef\u63a7\u7684\uff0c\u5728\u80fd\u5ffd\u7565\u7684\u8303\u56f4\u5185\u3002<\/p>\n\n\n\n<p>Python \u4e2d\u5b57\u5178\u7684\u641c\u7d22\u662f\u57fa\u4e8e\u54c8\u5e0c\u67e5\u627e\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(1)\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"477\" height=\"208\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/9B86A49FCEDD36446BE24BFB0167E368.jpg\" alt=\"\" class=\"wp-image-2899 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/9B86A49FCEDD36446BE24BFB0167E368.jpg 477w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/9B86A49FCEDD36446BE24BFB0167E368-300x131.jpg 300w\" data-sizes=\"(max-width: 477px) 100vw, 477px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 477px; --smush-placeholder-aspect-ratio: 477\/208;\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"C\"><\/span>C<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/**\n * Note: The returned array must be malloced, assume caller calls free().\n *\/\nint* twoSum(int* nums, int numsSize, int target, int* returnSize){\n    int *result = (int *) malloc(sizeof(int *) * 2);  \/\/ \u7533\u8bf7\u4e24\u4e2a\u6574\u6570\u5927\u5c0f\u7684\u5185\u5b58\u7a7a\u95f4\n    memset(result, 0, sizeof(result));  \/\/ \u521d\u59cb\u5316\u4e3a 0\n    \n    for (int i = 0; i &lt; numsSize - 1; ++i)\n    {\n        for (int j = i + 1; j &lt; numsSize; ++j)\n        {\n            if (nums[i] + nums[j] == target)\n            {\n                result[0] = i;\n                result[1] = j;\n            }\n        }\n    }\n    *returnSize = 2;  \/\/ \u8bf4\u5b9e\u8bdd\u6ca1\u7406\u89e3\u8fd9\u4e2a\u53c2\u6570\u7684\u610f\u4e49\uff0c\u660e\u660e\u9898\u76ee\u8bf4\u4e86\u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\u7684\u4e0b\u6807\uff0c\u8fd8\u8981\u6211\u6765\u544a\u8bc9\uff1f\n    return result;\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"416\" height=\"210\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-51.png\" alt=\"\" class=\"wp-image-2901 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-51.png 416w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-51-300x151.png 300w\" data-sizes=\"(max-width: 416px) 100vw, 416px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 416px; --smush-placeholder-aspect-ratio: 416\/210;\" \/><\/figure>\n\n\n\n<p>\u8fd9\u4e2a\u4e5f\u662f\u66b4\u529b\u679a\u4e3e\u6cd5\uff0c\u4e0d\u8fc7\u548c Python \u6bd4\u8d77\u6765\uff0c\u901f\u5ea6\u8fd8\u662f\u5feb\u4e00\u500d\u5de6\u53f3\u3002\u5f53\u7136\u8fd9\u662f\u5728\u4f20\u5165\u6570\u7ec4\u53ea\u6709\u51e0\u4e2a\u5143\u7d20\u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u6210\u767e\u4e0a\u5343\u5904\u7406\u7684\u65f6\u5019\uff0c\u5dee\u8ddd\u5e94\u8be5\u5c31\u4f1a\u660e\u663e\u8d77\u6765\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/**\n    @struct \u7c7b\u4f3c\u4e8e Python \u4e2d\u5b57\u5178\u7684\u7ed3\u6784\uff08\u952e-\u503c\uff09\n *\/\ntypedef struct hashTable\n{\n    int key;\n    int val;\n    UT_hash_handle hh;  \/\/ uthash\uff1ahttps:\/\/github.com\/troydhanson\/uthash\n} hashTable;\n\nhashTable *hashtable = NULL;\n\n\/**\n    @brief \u67e5\u627e\u54c8\u5e0c\u8868\n    @param key \u67e5\u627e\u503c\n    @return \u627e\u5230\u7684\u54c8\u5e0c\u8282\u70b9\uff0c\u672a\u627e\u5230\u8fd4\u56de NULL\n *\/\nhashTable *find(int key)\n{\n    hashTable *tmp;\n    HASH_FIND_INT(hashtable, &amp;key, tmp);\n    return tmp;\n}\n\n\/**\n    @brief \u54c8\u5e0c\u8868\u63d2\u503c\n    @param ikey \u63d2\u5165\u952e\n    @param ival \u63d2\u5165\u503c\n *\/\nvoid insert(int ikey, int ival)\n{\n    hashTable *it = find(ikey);\n    if (it == NULL)  \/\/ \u4e0d\u5b58\u5728\u5219\u63d2\u503c\n    {\n        hashTable *tmp = (hashTable *) malloc(sizeof(hashTable));\n        tmp->key = ikey;\n        tmp->val = ival;\n        HASH_ADD_INT(hashtable, key, tmp);\n    }\n    else  \/\/ \u5b58\u5728\u5219\u4fee\u6539\n    {\n        it->val = ival;\n    }\n}\n\n\nint *twoSum(int *nums, int numsSize, int target, int *returnSize)\n{\n    hashtable = NULL;\n    for (int i = 0; i &lt; numsSize; ++i)\n    {\n        hashTable *it = find(target - nums[i]);\n        if (it != NULL)\n        {\n            int *ret = (int *) malloc(sizeof(int) * 2);\n            ret[0] = it->val;\n            ret[1] = i;\n            *returnSize = 2;\n            return ret;\n        }\n        insert(nums[i], i);\n    }\n    *returnSize = 0;\n    return NULL;\n}\n<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"423\" height=\"212\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-53.png\" alt=\"\" class=\"wp-image-2907 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-53.png 423w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2022\/01\/image-53-300x150.png 300w\" data-sizes=\"(max-width: 423px) 100vw, 423px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 423px; --smush-placeholder-aspect-ratio: 423\/212;\" \/><\/figure>\n\n\n\n<p>\u8be5\u7b97\u6cd5\u7684\u67e5\u627e\u90e8\u5206\u662f\u57fa\u4e8e\u54c8\u5e0c\u67e5\u627e\uff0c\u4ee3\u7801\u4e2d\u5b9e\u73b0\u4e86\u4e00\u4e2a\u7c7b\u4f3c\u4e8e Python \u5b57\u5178\u7684\u7ed3\u6784\u3002\u601d\u8def\u4e3b\u4f53\u548c Python \u7684\u4e00\u6837\uff0c\u4f46\u662f\u6709\u70b9\u5c0f\u4e0d\u540c\u3002Python \u4ee3\u7801\u6211\u5199\u7684\u662f\u5148\u5c06\u6240\u6709\u6570\u7ec4\u5143\u7d20\u63d2\u5165\u5b57\u5178\uff0c\u540e\u9762\u5faa\u73af\u7684\u67e5\u627e\u7684\u65f6\u5019\uff0c\u6bcf\u6b21\u67e5\u627e\u90fd\u8981\u5c06\u6240\u6709\u6570\u7ec4\u5143\u7d20\u641c\u7d22\u4e00\u904d\u3002\u800c\u8fd9\u91cc\u6211\u7528 C \u5199\u7684\u65f6\u5019\u6362\u4e86\u4e2a\u65b9\u5f0f\uff0c\u54c8\u5e0c\u8868\u5148\u4e3a\u7a7a\uff0c\u6bcf\u6b21\u5faa\u73af\u67e5\u627e\uff0c\u5982\u679c\u6ca1\u627e\u5230\uff0c\u5219\u5c06\u5f53\u6b64\u5faa\u73af\u7684\u6570\u7ec4\u5143\u7d20\u548c\u4e0b\u6807\u63d2\u5165\uff0c\u63d2\u5165\u4e00\u6b21\u540e\u54c8\u5e0c\u8868\u6709\u4e00\u4e2a\u5143\u7d20\uff0c\u4e0b\u4e00\u6b21\u5faa\u73af\u4ece\u4e0a\u4e00\u8f6e\u63d2\u5165\u540e\u7684\u54c8\u5e0c\u8868\u4e2d\u641c\u7d22\uff0c\u5982\u679c\u53c8\u6ca1\u627e\u5230\uff0c\u53c8\u518d\u63d2\u5165\uff0c\u624d\u6709\u4e24\u4e2a\u5143\u7d20\uff0c\u6700\u574f\u7684\u60c5\u51b5\u662f\uff0c\u6570\u7ec4\u6700\u540e\u4e24\u4e2a\u5143\u7d20\u6ee1\u8db3\u8981\u6c42\uff0c\u5219\u6700\u540e\u4e00\u6b21\u5faa\u73af\u65f6\uff0c\u54c8\u5e0c\u8868\u5143\u7d20\u4e2a\u6570\u624d\u662f n-1 \u4e2a\u3002\u5373\u76f8\u5bf9\u5199 Python \u4ee3\u7801\u7684\u90a3\u4e2a\u601d\u8def\uff0c\u6bcf\u6b21\u5faa\u73af\u90fd\u4ece n \u4e2a\u5143\u7d20\u91cc\u641c\u7d22\u5904\u7406\u91cf\u66f4\u5c0f\u4e00\u70b9\uff0c\u603b\u4f53\u4e0a\u5bf9\u4e8e\u54c8\u5e0c\u67e5\u627e\u5dee\u5f02\u5176\u5b9e\u5e76\u4e0d\u662f\u5f88\u5927\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee \u7ed9\u5b9a\u4e00\u4e2a\u6574\u6570\u6570\u7ec4 nums&nbsp;\u548c\u4e00\u4e2a\u6574\u6570\u76ee\u6807\u503c target\uff0c\u8bf7\u4f60\u5728\u8be5\u6570\u7ec4\u4e2d\u627e\u51fa \u548c\u4e3a\u76ee\u6807\u503c t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-2890","post","type-post","status-publish","format-standard","hentry","category-all"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/2890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2890"}],"version-history":[{"count":0,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/2890\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}