{"id":169,"date":"2024-09-21T16:47:03","date_gmt":"2024-09-21T08:47:03","guid":{"rendered":"https:\/\/www.xxinran.tech\/?p=169"},"modified":"2024-10-17T22:28:57","modified_gmt":"2024-10-17T14:28:57","slug":"c%e8%af%ad%e8%a8%80%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84-%e9%93%be%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/www.xxinran.tech\/index.php\/2024\/09\/21\/c%e8%af%ad%e8%a8%80%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84-%e9%93%be%e8%a1%a8\/","title":{"rendered":"C\u8bed\u8a00\u6570\u636e\u7ed3\u6784\u2014\u2014\u94fe\u8868"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u524d\u8a00<\/h2>\n\n\n\n<p>\u597d\u7684\uff0c\u4e00\u523b\u4e5f\u6ca1\u6709\u4e3a\u4e86\u987a\u5e8f\u8868\u7684\u5b66\u4e60\u7ed3\u675f\u800c\u611f\u5230\u56de\u5473\u65e0\u7a77\uff0c\u63a5\u4e0b\u6765\u8ba9\u6211\u4eec\u6709\u8bf7\u4e0b\u4e00\u4e2a\u9009\u624b\u2014\u2014\u94fe\u8868\u7684\u767b\u573a\u3002<\/p>\n\n\n\n<p>\u540c\u4e3a\u7ebf\u6027\u7ed3\u6784\u7684\u94fe\u8868\u4e0e\u987a\u5e8f\u8868\u4e4b\u95f4\u76f8\u5dee\u7684\u53ef\u4e0d\u6b62\u4e00\u70b9\u534a\u70b9\uff0c\u5728\u4f7f\u7528\u573a\u666f\u4e0a\u4e5f\u662f\u5343\u5dee\u4e07\u522b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ecb\u7ecd<\/h2>\n\n\n\n<p>\u94fe\u8868\u662f\u4e00\u79cd\u7269\u7406\u5b58\u50a8\u5355\u5143\u4e0a\u975e\u8fde\u7eed\u3001\u975e\u987a\u5e8f\u7684\u5b58\u50a8\u7ed3\u6784\uff0c\u6570\u636e\u5143\u7d20\u7684\u903b\u8f91\u987a\u5e8f\u662f\u901a\u8fc7\u94fe\u8868\u4e2d\u7684\u6307\u9488\u94fe\u63a5\u6b21\u5e8f\u5b9e\u73b0\u7684\u3002\u94fe\u8868\u7531\u4e00\u7cfb\u5217\u7ed3\u70b9\uff08\u94fe\u8868\u4e2d\u6bcf\u4e00\u4e2a\u5143\u7d20\u79f0\u4e3a\u7ed3\u70b9\uff09\u7ec4\u6210\uff0c\u7ed3\u70b9\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u751f\u6210\u3002\u6bcf\u4e2a\u7ed3\u70b9\u5305\u62ec\u4e24\u4e2a\u90e8\u5206\uff1a\u4e00\u4e2a\u662f\u5b58\u50a8\u6570\u636e\u5143\u7d20\u7684\u6570\u636e\u57df\uff0c\u53e6\u4e00\u4e2a\u662f\u5b58\u50a8\u4e0b\u4e00\u4e2a\u7ed3\u70b9\u5730\u5740\u7684\u6307\u9488\u57df\u3002 \u76f8\u6bd4\u4e8e\u7ebf\u6027\u8868\u987a\u5e8f\u7ed3\u6784\uff0c\u64cd\u4f5c\u590d\u6742\u3002\u7531\u4e8e\u4e0d\u5fc5\u987b\u6309\u987a\u5e8f\u5b58\u50a8\uff0c\u94fe\u8868\u5728\u63d2\u5165\u7684\u65f6\u5019\u53ef\u4ee5\u8fbe\u5230O(1)\u7684\u590d\u6742\u5ea6\uff0c\u6bd4\u53e6\u4e00\u79cd\u7ebf\u6027\u8868\u987a\u5e8f\u8868\u5feb\u5f97\u591a\uff0c\u4f46\u662f\u67e5\u627e\u4e00\u4e2a\u8282\u70b9\u6216\u8005\u8bbf\u95ee\u7279\u5b9a\u7f16\u53f7\u7684\u8282\u70b9\u5219\u9700\u8981O(n)\u7684\u65f6\u95f4\uff0c\u800c\u7ebf\u6027\u8868\u548c\u987a\u5e8f\u8868\u76f8\u5e94\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u5206\u522b\u662fO(logn)\u548cO(1)\u3002<\/p>\n\n\n\n<p>\u94fe\u8868\u5206\u4e3a\u5355\u94fe\u8868\u3001\u5faa\u73af\u94fe\u8868\u4ee5\u53ca\u53cc\u5411\u94fe\u8868\u3002\u4e0b\u9762\u6211\u4f1a\u4e00\u4e2a\u4e2a\u8fdb\u884c\u89e3\u91ca\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5355\u94fe\u8868<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5355\u94fe\u8868\u7684\u5b9a\u4e49\u548c\u8868\u793a<\/h3>\n\n\n\n<p>\u5355\u94fe\u8868\u662f\u4e00\u79cd\u7ebf\u6027\u6570\u636e\u7ed3\u6784\uff0c\u5176\u4e2d\u6bcf\u4e2a\u5143\u7d20\uff08\u79f0\u4e3a\u8282\u70b9\uff09\u5305\u542b\u4e24\u4e2a\u90e8\u5206\uff1a\u6570\u636e\u57df\u548c\u6307\u5411\u4e0b\u4e00\u4e2a\u8282\u70b9\u7684\u6307\u9488\u3002\u5728\u5355\u94fe\u8868\u4e2d\uff0c\u6700\u540e\u4e00\u4e2a\u8282\u70b9\u7684\u6307\u9488\u901a\u5e38\u8bbe\u7f6e\u4e3a <code>NULL<\/code>\uff0c\u8868\u793a\u94fe\u8868\u7684\u7ed3\u675f\u3002\u8fd9\u79cd\u7ed3\u6784\u4f7f\u5f97\u5355\u94fe\u8868\u975e\u5e38\u9002\u5408\u52a8\u6001\u7684\u6570\u636e\u96c6\u5408\uff0c\u56e0\u4e3a\u5b83\u4e0d\u9700\u8981\u8fde\u7eed\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u5e76\u4e14\u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c\u76f8\u5bf9\u9ad8\u6548\u3002\u5355\u94fe\u8868\u662f\u7531\u8868\u5934\u552f\u4e00\u786e\u5b9a\uff0c\u56e0\u6b64\u5355\u94fe\u8868\u53ef\u4ee5\u7528\u5934\u6307\u9488\u7684\u540d\u5b57\u6765\u547d\u540d\uff0c\u82e5\u5934\u6307\u9488\u540d\u662fL\uff0c\u5219\u628a\u94fe\u8868\u79f0\u4e3a\u8868L\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u653e\u4e00\u4e2a\u5355\u94fe\u8868\u7684\u903b\u8f91\u72b6\u6001\u56fe\u548c\u5b58\u50a8\u7ed3\u6784\u56fe\u65b9\u4fbf\u7406\u89e3<\/p>\n\n\n\n<p>\u5b58\u50a8\u7ed3\u6784\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"829\" height=\"487\" src=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726735200-\u5c4f\u5e55\u622a\u56fe-2024-09-15-1332012.png\" alt=\"\" class=\"wp-image-170\" srcset=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726735200-\u5c4f\u5e55\u622a\u56fe-2024-09-15-1332012.png 829w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726735200-\u5c4f\u5e55\u622a\u56fe-2024-09-15-1332012-300x176.png 300w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726735200-\u5c4f\u5e55\u622a\u56fe-2024-09-15-1332012-768x451.png 768w\" sizes=\"(max-width: 829px) 100vw, 829px\" \/><\/figure>\n\n\n\n<p>\u8fd9\u4e2a\u56fe\u4e2d\u5c55\u73b0\u4e86\u5355\u94fe\u8868\u5b58\u50a8\u7ed3\u6784\u7684\u7279\u70b9\u4e0d\u9700\u8981\u8fde\u7eed\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u8fd9\u4e5f\u662f\u548c\u524d\u9762\u7684\u987a\u5e8f\u8868\u4e0d\u540c\u7684\u4e00\u70b9\uff0c\u987a\u5e8f\u8868\u9700\u8981\u5360\u7528\u4e00\u5757\u8fde\u7eed\u7684\u5b58\u50a8\u7a7a\u95f4\u3002\u6307\u9488\u4e3a\u6570\u636e\u5143\u7d20\u4e4b\u95f4\u903b\u8f91\u5173\u7cfb\u7684\u6620\u50cf\uff0c\u5219\u903b\u8f91\u4e0a\u76f8\u90bb\u7684\u4e24\u4e2a\u6570\u636e\u5143\u7d20\u5176\u5b58\u50a8\u7684\u7269\u7406\u4f4d\u7f6e\u4e0d\u8981\u6c42\u7d27\u90bb\uff0c\u8fd9\u79cd\u5b58\u50a8\u7ed3\u6784\u4e3a\u975e\u987a\u5e8f\u6620\u50cf\u6216\u94fe\u5f0f\u6620\u50cf\u3002<\/p>\n\n\n\n<p>\u903b\u8f91\u72b6\u6001\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"209\" src=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726735590-\u5c4f\u5e55\u622a\u56fe-2024-09-19-164441-1024x209.png\" alt=\"\" class=\"wp-image-171\" srcset=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726735590-\u5c4f\u5e55\u622a\u56fe-2024-09-19-164441-1024x209.png 1024w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726735590-\u5c4f\u5e55\u622a\u56fe-2024-09-19-164441-300x61.png 300w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726735590-\u5c4f\u5e55\u622a\u56fe-2024-09-19-164441-768x157.png 768w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726735590-\u5c4f\u5e55\u622a\u56fe-2024-09-19-164441-1536x314.png 1536w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726735590-\u5c4f\u5e55\u622a\u56fe-2024-09-19-164441.png 1601w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u56fe\u4e2d\uff0c\u53ef\u4ee5\u770b\u51fa\u524d\u4e00\u4e2a\u8282\u70b9\u7684\u6307\u9488\u57df\u6307\u5411\u4e0e\u5b83\u6709\u903b\u8f91\u5173\u7cfb\u7684\u4e0b\u4e00\u4e2a\u7ed3\u70b9\u5b58\u50a8\u5730\u5740\uff0c\u5728\u4f7f\u7528\u94fe\u8868\u65f6\uff0c\u5173\u5fc3\u7684\u53ea\u662f\u5b83\u6240\u8868\u793a\u7684\u7ebf\u6027\u8868\u4e2d\u6570\u636e\u5143\u7d20\u4e4b\u95f4\u7684\u903b\u8f91\u987a\u5e8f\uff0c\u800c\u4e0d\u662f\u6bcf\u4e2a\u6570\u636e\u5143\u7d20\u5728\u5b58\u50a8\u5668\u4e2d\u7684\u5b9e\u9645\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<p>\u7531\u6b64\u53ef\u89c1\uff0c\u5355\u94fe\u8868\u53ef\u7531\u5934\u6307\u9488\u552f\u4e00\u786e\u5b9a\u3002\u5177\u4f53\u5b9e\u73b0\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>typedef struct LNode {\n\tElemType elem;     \/\/\u7ed3\u70b9\u7684\u6570\u636e\u57df\n\tstruct LNode* next;\/\/\u7ed3\u70b9\u7684\u6307\u9488\u57df\n}LNode, * LinkList;        \/\/LinkList\u4e3a\u6307\u5411\u7ed3\u6784\u4f53LNode\u7684\u6307\u9488\u7c7b\u578b<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u5b9a\u4e49\u7684\u662f\u5355\u94fe\u8868\u4e2d\u6bcf\u4e2a\u7ed3\u70b9\u7684\u5b58\u50a8\u7ed3\u6784\uff0c\u5b83\u5305\u62ec\u4e24\u90e8\u5206\uff1a\u5b58\u50a8\u7ed3\u70b9\u7684\u6570\u636e\u57df elem \uff0c\u5176\u7c7b\u578b\u7528\u901a\u7528\u7684\u7c7b\u578b\u6807\u8bc6\u7b26ElemType\u8868\u793a\uff08\u4f8b\u5982\uff0c\u5982\u679c\u7528\u94fe\u8868\u8868\u793a\u4e4b\u524d\u5728\u987a\u5e8f\u8868\u4e2d\u7684\u56fe\u4e66\u4fe1\u606f\uff0c\u53ea\u9700\u5c06ElemType\u66ff\u6362\u4e3a\u5b9a\u4e49\u7684Book\u6570\u636e\u7c7b\u578b\u5373\u53ef\uff09\uff1b\u5b58\u50a8\u540e\u7ee7\u7ed3\u70b9\u4f4d\u7f6e\u7684\u6307\u9488\u57dfnext\uff0c\u5176\u7c7b\u578b\u6307\u5411\u7ed3\u70b9\u7684\u6307\u9488\u7c7b\u578bLNode*\uff1b<\/p>\n\n\n\n<p>\u8fd9\u91cc\u518d\u8be6\u7ec6\u89e3\u91ca\u4e00\u4e0b\u8fd9\u53e5 struct LNode *next\u3002\u8fd9\u662f\u4e2a\u6307\u9488\uff0c\u6307\u5411\u7684\u662fstruct LNode\u8fd9\u79cd\u7c7b\u578b\u7684\u6307\u9488\uff0c\u90a3\u4e48struct LNode\u8fd9\u79cd\u7c7b\u578b\u6709\u662f\u4ec0\u4e48\u7c7b\u578b\u5462\uff1f\u8fd9\u79cd\u7c7b\u578b\u53c8\u5305\u62ec\u8fd9\u6837\u7684\u4e24\u4e2a\u6210\u5458\u7684\u4e00\u4e2a\u6307\u9488\uff0c\u8fd9\u79cd\u662f\u7528\u81ea\u5df1\u6765\u5b9a\u4e49\u81ea\u5df1\uff0c\u672c\u6765\u5b9a\u4e49\u4e00\u4e2a\u7c7b\u578b\u53ebstruct LNode\uff0c\u7136\u540e\u6211\u8fd9\u4e2a\u91cc\u9762\u7684\u6210\u5458struct LNode *next\u6709\u662f\u8fd9\u4e2a\u7c7b\u578b\uff0c\u8fd9\u79cd\u5b9a\u4e49\u65b9\u5f0f\u53eb\u505a\u5d4c\u5957\u7684\u5b9a\u4e49\u3002<\/p>\n\n\n\n<p>LNode\u6307\u7684\u662f\u4e00\u4e2a\u7ed3\u70b9\u800c*LinkList\u5c31\u662f\u6307\u5411\u8fd9\u79cd\u7ed3\u6784\u7ed3\u70b9\u7684\u4e00\u4e2a\u6307\u9488\u7c7b\u578b\uff0c\u6211\u4eec\u518d\u6765\u5b9a\u4e49\u7684\u65f6\u5019\u5c31\u4e0d\u9700\u8981\u52a0*\u53f7\u4e86\uff0c\u5c31\u6bd4\u8f83\u65b9\u4fbf\uff0c\u6bd4\u5982\u8bf4\u5934\u7ed3\u70b9L\uff0c\u6211\u4eec\u53ef\u4ee5\u7528LNode *L\u6307\u5411\u8fd9\u79cd\u7ed3\u70b9\u7684\u4e00\u4e2a\u6307\u9488\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u7528LinkList L\u66f4\u52a0\u7b80\u5355\uff0c\u56e0\u4e3aLinkList\u672c\u8eab\u5c31\u662f\u6307\u5411\u8fd9\u79cd\u7c7b\u578b\u7684\u4e00\u4e2a\u6307\u9488\u3002\u5b9a\u4e49\u7ed3\u70b9\u6307\u9488p\u901a\u5e38\u4f7f\u7528LNode *p\u7684\u65b9\u5f0f\uff0c\u800c\u4e0d\u662fLinkList p\u7684\u65b9\u5f0f<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u8bb2\u4e00\u4e0b\u524d\u8fb9\u4e00\u76f4\u5728\u63d0\u5230\u7684\u5934\u7ed3\u70b9\uff0c\u9996\u5143\u7ed3\u70b9\uff0c\u5934\u6307\u9488\u7684\u6982\u5ff5\uff0c\u540c\u65f6\u4e5f\u9632\u6b62\u628a\u8fd9\u4e09\u4e2a\u6982\u5ff5\u6df7\u6dc6\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5934\u7ed3\u70b9 (Header Node)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5b9a\u4e49<\/strong>\uff1a\u5934\u7ed3\u70b9\u662f\u4f4d\u4e8e\u94fe\u8868\u6700\u524d\u7aef\u7684\u4e00\u4e2a\u7279\u6b8a\u8282\u70b9\uff0c\u5b83\u5e76\u4e0d\u5b58\u50a8\u5b9e\u9645\u7684\u6570\u636e\u5143\u7d20\uff0c\u800c\u662f\u4f5c\u4e3a\u4e00\u4e2a\u8f85\u52a9\u8282\u70b9\u5b58\u5728\u3002<\/li>\n\n\n\n<li><strong>\u4f5c\u7528<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u4fbf\u4e8e\u5bf9\u94fe\u8868\u7684\u64cd\u4f5c\uff0c\u6bd4\u5982\u5728\u94fe\u8868\u5934\u90e8\u63d2\u5165\u6216\u5220\u9664\u8282\u70b9\u65f6\uff0c\u4e0d\u9700\u8981\u5355\u72ec\u5904\u7406\u7a7a\u94fe\u8868\u7684\u60c5\u51b5\u3002<\/li>\n\n\n\n<li>\u53ef\u4ee5\u7edf\u4e00\u64cd\u4f5c\uff0c\u4f7f\u5f97\u7b97\u6cd5\u66f4\u52a0\u7b80\u6d01\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u7279\u70b9<\/strong>\uff1a\u5934\u7ed3\u70b9\u7684&nbsp;<code>data<\/code>&nbsp;\u57df\u901a\u5e38\u4e0d\u4f7f\u7528\uff0c\u800c\u5b83\u7684&nbsp;<code>next<\/code>&nbsp;\u6307\u9488\u6307\u5411\u771f\u6b63\u7684\u7b2c\u4e00\u4e2a\u6570\u636e\u8282\u70b9\uff08\u5373\u9996\u5143\u7ed3\u70b9\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u9996\u5143\u7ed3\u70b9 (First Data Node \u6216 Head Element Node)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5b9a\u4e49<\/strong>\uff1a\u9996\u5143\u7ed3\u70b9\u662f\u6307\u94fe\u8868\u4e2d\u7b2c\u4e00\u4e2a\u5b58\u50a8\u5b9e\u9645\u6570\u636e\u7684\u8282\u70b9\u3002<\/li>\n\n\n\n<li><strong>\u4f5c\u7528<\/strong>\uff1a\u5b83\u662f\u94fe\u8868\u4e2d\u771f\u6b63\u5f00\u59cb\u5b58\u653e\u6570\u636e\u7684\u5730\u65b9\u3002<\/li>\n\n\n\n<li><strong>\u7279\u70b9<\/strong>\uff1a\u5728\u6ca1\u6709\u5934\u7ed3\u70b9\u7684\u60c5\u51b5\u4e0b\uff0c\u9996\u5143\u7ed3\u70b9\u5c31\u662f\u94fe\u8868\u7684\u7b2c\u4e00\u4e2a\u8282\u70b9\uff1b\u5982\u679c\u6709\u5934\u7ed3\u70b9\uff0c\u90a3\u4e48\u9996\u5143\u7ed3\u70b9\u662f\u5934\u7ed3\u70b9\u4e4b\u540e\u7684\u7b2c\u4e00\u4e2a\u8282\u70b9\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u5934\u6307\u9488 (Head Pointer)<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5f53\u94fe\u8868\u4e3a\u7a7a\u65f6\uff0c\u5934\u6307\u9488\u53ef\u80fd\u4e3a&nbsp;<code>NULL<\/code>\uff0c\u6216\u8005\u6307\u5411\u4e00\u4e2a\u53ea\u542b\u6709\u5934\u7ed3\u70b9\u7684\u94fe\u8868\u3002<\/li>\n\n\n\n<li><strong>\u5b9a\u4e49<\/strong>\uff1a\u5934\u6307\u9488\u662f\u4e00\u4e2a\u6307\u5411\u94fe\u8868\u8d77\u59cb\u4f4d\u7f6e\u7684\u6307\u9488\u3002\u5b83\u53ef\u4ee5\u6307\u5411\u5934\u7ed3\u70b9\uff08\u5982\u679c\u6709\u7684\u8bdd\uff09\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u6307\u5411\u9996\u5143\u7ed3\u70b9\u3002<\/li>\n\n\n\n<li><strong>\u4f5c\u7528<\/strong>\uff1a\u901a\u8fc7\u5934\u6307\u9488\u53ef\u4ee5\u8bbf\u95ee\u6574\u4e2a\u94fe\u8868\u3002<\/li>\n\n\n\n<li><strong>\u7279\u70b9<\/strong>\uff1a<\/li>\n\n\n\n<li>\u5982\u679c\u94fe\u8868\u6709\u5934\u7ed3\u70b9\uff0c\u5934\u6307\u9488\u901a\u5e38\u6307\u5411\u5934\u7ed3\u70b9\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u94fe\u8868\u6ca1\u6709\u5934\u7ed3\u70b9\uff0c\u5934\u6307\u9488\u5219\u76f4\u63a5\u6307\u5411\u9996\u5143\u7ed3\u70b9\u3002<\/li>\n\n\n\n<li>\u5f53\u94fe\u8868\u4e3a\u7a7a\u65f6\uff0c\u5934\u6307\u9488\u53ef\u80fd\u4e3a&nbsp;<code>NULL<\/code>\uff0c\u6216\u8005\u6307\u5411\u4e00\u4e2a\u53ea\u542b\u6709\u5934\u7ed3\u70b9\u7684\u94fe\u8868\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8bb2\u5b8c\u4e86\u5934\u7ed3\u70b9\uff0c\u9996\u5143\u7ed3\u70b9\uff0c\u5934\u6307\u9488\u7684\u6982\u5ff5\uff0c\u8865\u5145\u4e00\u4e0b\u4e3a\u4ec0\u4e48\u94fe\u8868\u8981\u589e\u52a0\u5934\u7ed3\u70b9\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5934\u7ed3\u70b9\u7684\u4f5c\u7528<\/h2>\n\n\n\n<p>\uff081\uff09\u4fbf\u4e8e\u9996\u5143\u7ed3\u70b9\u7684\u5904\u7406<\/p>\n\n\n\n<p>\u589e\u52a0\u4e86\u5934\u7ed3\u70b9\u4e4b\u540e\uff0c\u9996\u5143\u7ed3\u70b9\u7684\u5730\u5740\u4fdd\u5b58\u5728\u5934\u7ed3\u70b9\uff08\u4e5f\u5c31\u662f\u5176\u201c\u524d\u9a71\u201d\u7ed3\u70b9\uff09\u7684\u6307\u9488\u57df\u4e2d\uff0c\u5219\u5bf9\u94fe\u8868\u7684\u7b2c\u4e00\u4e2a\u6570\u636e\u5143\u7d20\u7684\u64cd\u4f5c\u4e0e\u5bf9\u5176\u4ed6\u6570\u636e\u5143\u7d20\u7684\u64cd\u4f5c\u76f8\u540c\uff0c\u65e0\u9700\u8fdb\u884c\u7279\u6b8a\u5904\u7406\u3002<\/p>\n\n\n\n<p>\u8fd9\u6837\u89e3\u91ca\u53ef\u80fd\u8fd8\u662f\u4e0d\u592a\u597d\u7406\u89e3\uff0c\u90a3\u54b1\u6765\u70b9\u72e0\u6d3b\u513f\uff01<\/p>\n\n\n\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u6ca1\u6709\u5934\u7ed3\u70b9\u7684\u5355\u94fe\u8868\uff0c\u5176\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>+-------+      +-------+      +-------+\n| head  | ----&gt; | data: | ----&gt;| data: | ----&gt; ... ----&gt; NULL\n|  10    |      |  20   |      |  30   |\n+---+---+      +---+---+      +---+---+\n   |                  |             |\n   v                   v            v\n (\u5934\u6307\u9488\/\u9996\u5143\u7ed3\u70b9)  (\u7b2c\u4e8c\u4e2a\u8282\u70b9)  (\u7b2c\u4e09\u4e2a\u8282\u70b9)<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c<code>head<\/code> \u6307\u5411\u7684\u662f\u7b2c\u4e00\u4e2a\u6570\u636e\u8282\u70b9\uff08\u5373\u9996\u5143\u7ed3\u70b9\uff09\uff0c\u5982\u679c\u6211\u4eec\u8981\u5728\u94fe\u8868\u5934\u90e8\u63d2\u5165\u4e00\u4e2a\u65b0\u8282\u70b9\u6216\u8005\u5220\u9664\u9996\u5143\u7ed3\u70b9\uff0c\u6211\u4eec\u9700\u8981\u7279\u522b\u5904\u7406 <code>head<\/code> \u6307\u9488\u3002\u4f8b\u5982\uff0c\u63d2\u5165\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u66f4\u65b0 <code>head<\/code> \u7684\u503c\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\u8003\u8651\u589e\u52a0\u4e86\u4e00\u4e2a\u5934\u7ed3\u70b9\u540e\u7684\u94fe\u8868\u7ed3\u6784\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>+------+      +-------+     +-------+      +-------+\n| head | ----&gt;| data:| ----&gt;| data: | ----&gt;| data: | ----&gt; ... ----&gt; NULL\n| next |      |  N\/A |      |  10   |      |  20   |\n+------+      +---+---+     +---+---+     +---+---+\n                   |            |               |\n                   v            v               v\n                 (\u5934\u7ed3\u70b9)     (\u9996\u5143\u7ed3\u70b9)      (\u7b2c\u4e8c\u4e2a\u8282\u70b9)<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0chead \u6307\u5411\u7684\u662f\u5934\u7ed3\u70b9\uff0c\u800c\u5934\u7ed3\u70b9\u7684 next \u6307\u9488\u6307\u5411\u4e86\u9996\u5143\u7ed3\u70b9\uff08\u5373\u7b2c\u4e00\u4e2a\u6570\u636e\u8282\u70b9\uff09\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u5934\u7ed3\u70b9\u63d0\u4f9b\u4e86\u4e00\u79cd\u7edf\u4e00\u7684\u63a5\u53e3\u6765\u5904\u7406\u94fe\u8868\u7684\u6240\u6709\u8282\u70b9\uff0c\u5305\u62ec\u7b2c\u4e00\u4e2a\u6570\u636e\u8282\u70b9\u3002\u56e0\u6b64\uff0c\u6dfb\u52a0\u3001\u5220\u9664\u7b49\u64cd\u4f5c\u53ef\u4ee5\u88ab\u7f16\u5199\u5f97\u66f4\u52a0\u901a\u7528\uff0c\u800c\u65e0\u9700\u9488\u5bf9\u9996\u5143\u7ed3\u70b9\u505a\u7279\u6b8a\u5904\u7406\u3002<\/p>\n\n\n\n<p>\uff082\uff09\u4fbf\u4e8e\u7a7a\u8868\u548c\u975e\u7a7a\u8868\u7684\u7edf\u4e00\u5904\u7406<\/p>\n\n\n\n<p>\u5f53\u94fe\u8868\u4e0d\u8bbe\u5934\u7ed3\u70b9\u65f6\uff0c\u5047\u8bbeL\u4e3a\u5355\u94fe\u8868\u7684\u5934\u6307\u9488\uff0c\u5b83\u5e94\u8be5\u6307\u5411\u9996\u5143\u7ed3\u70b9\uff0c\u5219\u5f53\u5355\u94fe\u8868\u4e3a\u957f\u5ea6n\u4e3a0\u7684\u7a7a\u8868\u65f6\uff0cL\u6307\u9488\u4e3a\u7a7a\uff08\u5224\u5b9a\u7a7a\u8868\u7684\u6761\u4ef6\u53ef\u8bb0\u4e3a\uff1aL==NULL\uff09\u3002<\/p>\n\n\n\n<p>\u589e\u52a0\u5934\u7ed3\u70b9\u4e4b\u540e\uff0c\u4e0d\u9700\u8981\u518d\u5355\u72ec\u5904\u7406\u7a7a\u94fe\u8868\u7684\u60c5\u51b5\uff0c\u56e0\u4e3a\u5373\u4f7f\u94fe\u8868\u4e3a\u7a7a\uff0c\u4e5f\u6709\u4e00\u4e2a\u5934\u7ed3\u70b9\u5b58\u5728\uff0cL-&gt;next \u5c06\u4f1a\u662f NULL\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u4e3e\u4e2a\u4f8b\u5b50<\/p>\n\n\n\n<p>\u793a\u4f8b\uff1a\u5728\u94fe\u8868\u5934\u90e8\u63d2\u5165\u65b0\u8282\u70b9<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u65e0\u5934\u7ed3\u70b9\u65f6<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u94fe\u8868\u4e3a\u7a7a\uff0c\u5219\u76f4\u63a5\u8ba9&nbsp;<code>head<\/code>&nbsp;\u6307\u5411\u65b0\u8282\u70b9\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u94fe\u8868\u4e0d\u4e3a\u7a7a\uff0c\u5219\u9700\u8981\u521b\u5efa\u65b0\u8282\u70b9\uff0c\u5e76\u8ba9\u5b83\u6307\u5411\u539f\u6765\u7684&nbsp;<code>head<\/code>\uff0c\u7136\u540e\u66f4\u65b0&nbsp;<code>head<\/code>&nbsp;\u4e3a\u65b0\u8282\u70b9\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u6709\u5934\u7ed3\u70b9\u65f6<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u521b\u5efa\u65b0\u8282\u70b9\u3002<\/li>\n\n\n\n<li>\u8ba9\u65b0\u8282\u70b9\u7684&nbsp;<code>next<\/code>&nbsp;\u6307\u5411\u5934\u7ed3\u70b9\u7684&nbsp;<code>next<\/code>\u3002<\/li>\n\n\n\n<li>\u66f4\u65b0\u5934\u7ed3\u70b9\u7684&nbsp;<code>next<\/code>&nbsp;\u4e3a\u65b0\u8282\u70b9\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>\u8fd9\u4e2a\u8fc7\u7a0b\u5bf9\u4e8e\u6709\u5934\u7ed3\u70b9\u7684\u94fe\u8868\u6765\u8bf4\u662f\u4e00\u81f4\u7684\uff0c\u4e0d\u7ba1\u94fe\u8868\u662f\u5426\u4e3a\u7a7a\uff0c\u90fd\u53ea\u9700\u8981\u6539\u53d8\u5934\u7ed3\u70b9\u7684 <code>next<\/code> \u6307\u9488\u5373\u53ef\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8865\u5145\u987a\u5e8f\u8868\u548c\u7ebf\u6027\u8868\u4e2dnew\u7684\u533a\u522b<\/h2>\n\n\n\n<p>\u5728C++\u4e2d\uff0c<code>L = new DNode;<\/code> \u548c <code>L.elem = new ElemType;<\/code> \u8fd9\u4e24\u884c\u4ee3\u7801\u6d89\u53ca\u7684\u662f\u4e0d\u540c\u7684\u5185\u5b58\u5206\u914d\u64cd\u4f5c\uff0c\u5b83\u4eec\u7528\u4e8e\u4e0d\u540c\u7684\u6570\u636e\u7ed3\u6784\u548c\u573a\u666f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>L = new LNode;<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7528\u9014<\/strong>\uff1a\u8fd9\u884c\u4ee3\u7801\u7528\u4e8e\u52a8\u6001\u5730\u521b\u5efa\u4e00\u4e2a&nbsp;<code>LNode<\/code>&nbsp;\u7ed3\u6784\u4f53\u5b9e\u4f8b\uff0c\u5e76\u5c06\u8be5\u5b9e\u4f8b\u7684\u5730\u5740\u8d4b\u503c\u7ed9\u6307\u9488&nbsp;<code>L<\/code>\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u7ed3\u6784<\/strong>\uff1a\u9002\u7528\u4e8e\u94fe\u8868\u3002<\/li>\n\n\n\n<li><strong>\u542b\u4e49<\/strong>\uff1a<code>LNode<\/code>&nbsp;\u662f\u4e00\u4e2a\u7ed3\u6784\u4f53\uff0c\u4ee3\u8868\u94fe\u8868\u4e2d\u7684\u4e00\u4e2a\u8282\u70b9\u3002\u6bcf\u4e2a\u8282\u70b9\u5305\u542b\u6570\u636e\u57df&nbsp;<code>elem<\/code>&nbsp;\u4ee5\u53ca\u4e00\u4e2a\u6307\u9488&nbsp;<code>next<\/code>\u3002<\/li>\n\n\n\n<li><strong>\u5185\u5b58\u5206\u914d<\/strong>\uff1a<code>new LNode<\/code>&nbsp;\u5206\u914d\u4e86\u8db3\u591f\u5b58\u50a8\u4e00\u4e2a&nbsp;<code>LNode<\/code>&nbsp;\u7ed3\u6784\u4f53\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u5e76\u8c03\u7528\u9ed8\u8ba4\u6784\u9020\u51fd\u6570\uff08\u5982\u679c\u6709\uff09\u6765\u521d\u59cb\u5316\u8fd9\u4e2a\u7ed3\u6784\u4f53\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><code>L.elem = new ElemType;<\/code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7528\u9014<\/strong>\uff1a\u8fd9\u884c\u4ee3\u7801\u7528\u4e8e\u52a8\u6001\u5730\u4e3a\u987a\u5e8f\u8868\u4e2d\u7684\u5143\u7d20\u6570\u7ec4\u5206\u914d\u5185\u5b58\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u7ed3\u6784<\/strong>\uff1a\u9002\u7528\u4e8e\u987a\u5e8f\u8868\uff08\u5373\u6570\u7ec4\u6216\u57fa\u4e8e\u6570\u7ec4\u5b9e\u73b0\u7684\u5217\u8868\uff09\u3002<\/li>\n\n\n\n<li><strong>\u542b\u4e49<\/strong>\uff1a<code>L<\/code>&nbsp;\u53ef\u80fd\u662f\u4e00\u4e2a\u7ed3\u6784\u4f53\u6216\u7c7b\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a&nbsp;<code>ElemType<\/code>&nbsp;\u7c7b\u578b\u7684\u6570\u7ec4&nbsp;<code>elem<\/code>\uff0c\u7528\u4e8e\u5b58\u50a8\u987a\u5e8f\u8868\u4e2d\u7684\u5143\u7d20\u3002<code>new ElemType<\/code>&nbsp;\u901a\u5e38\u4f1a\u5206\u914d\u4e00\u4e2a\u56fa\u5b9a\u5927\u5c0f\u7684\u6570\u7ec4\u3002<\/li>\n\n\n\n<li><strong>\u5185\u5b58\u5206\u914d<\/strong>\uff1a<code>new ElemType[capacity]<\/code>&nbsp;\u5206\u914d\u4e86\u4e00\u4e2a\u53ef\u4ee5\u5b58\u50a8&nbsp;<code>capacity<\/code>&nbsp;\u4e2a&nbsp;<code>ElemType<\/code>&nbsp;\u5143\u7d20\u7684\u6570\u7ec4\uff0c\u5e76\u8fd4\u56de\u6307\u5411\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u6307\u9488\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>L = new LNode;<\/code><\/strong>&nbsp;\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u5355\u72ec\u7684\u94fe\u8868\u8282\u70b9\uff0c\u9002\u7528\u4e8e\u94fe\u8868\u7b49\u52a8\u6001\u6570\u636e\u7ed3\u6784\u3002<\/li>\n\n\n\n<li><strong><code>L.elem = new ElemType[capacity];<\/code><\/strong>&nbsp;\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u6570\u7ec4\uff0c\u9002\u7528\u4e8e\u987a\u5e8f\u8868\u7b49\u9759\u6001\u6570\u636e\u7ed3\u6784\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4e24\u8005\u90fd\u4f7f\u7528\u4e86 <code>new<\/code> \u5173\u952e\u5b57\u6765\u8fdb\u884c\u52a8\u6001\u5185\u5b58\u5206\u914d\uff0c\u4f46\u5b83\u4eec\u5206\u914d\u7684\u5bf9\u8c61\u7c7b\u578b\u4e0d\u540c\uff0c\u4e00\u4e2a\u662f\u5355\u4e2a\u8282\u70b9\u7ed3\u6784\u4f53\uff0c\u53e6\u4e00\u4e2a\u662f\u5143\u7d20\u6570\u7ec4\u3002\u5728\u4f7f\u7528\u8fd9\u4e9b\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\u65f6\uff0c\u8bb0\u5f97\u5728\u4e0d\u518d\u9700\u8981\u65f6\u901a\u8fc7 <code>delete<\/code> \u6216 <code>delete[]<\/code> \u6765\u91ca\u653e\u5185\u5b58\uff0c\u4ee5\u907f\u514d\u5185\u5b58\u6cc4\u6f0f\u3002\u5bf9\u4e8e <code>new DNode<\/code> \u4f7f\u7528 <code>delete<\/code>\uff0c\u800c\u5bf9\u4e8e <code>new ElemType[capacity]<\/code> \u4f7f\u7528 <code>delete[]<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5355\u94fe\u8868\u7684\u57fa\u672c\u64cd\u4f5c<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5355\u94fe\u8868\u7684\u521d\u59cb\u5316<\/h3>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u751f\u6210\u65b0\u7ed3\u70b9\u4f5c\u4e3a\u5934\u7ed3\u70b9\uff0c\u7528\u5934\u6307\u9488L\u6307\u5411\u5934\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p>\u2461\u5934\u7ed3\u70b9\u7684\u6307\u9488\u57df\u7f6e\u7a7a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int InitList(LinkList&amp; L) {\n\tL = new  LNode;\n\tL-&gt;next = NULL;\n\treturn OK;\n}<\/code><\/pre>\n\n\n\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6<\/strong>\uff1aO(1)\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5355\u94fe\u8868\u7684\u53d6\u503c<\/h3>\n\n\n\n<p>\u548c\u987a\u5e8f\u8868\u4e0d\u540c\uff0c\u94fe\u8868\u4e2d\u903b\u8f91\u76f8\u90bb\u7684\u7ed3\u70b9\u5e76\u6ca1\u6709<\/p>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u7528\u6307\u9488p\u6307\u9488\u6307\u5411\u9996\u5143\u7ed3\u70b9\uff0c\u7528 j \u505a\u8ba1\u6570\u5668\u521d\u8d4b\u503c\u4e3a1.<\/p>\n\n\n\n<p>\u2461\u4ece\u9996\u5143\u7ed3\u70b9\u5f00\u59cb\u4f9d\u6b21\u987a\u7740\u94fe\u57dfnext\u5411\u4e0b\u8bbf\u95ee\uff0c\u53ea\u8981\u6307\u5411\u5f53\u524d\u7ed3\u70b9\u7684\u6307\u9488p\u4e0d\u4e3a\u7a7a\uff08NULL\uff09\uff0c\u5e76\u4e14\u6ca1\u6709\u8fbe\u5230\u5e8f\u53f7\u4e3a i \u7684\u7ed3\u70b9\uff0c\u5219\u5faa\u73af\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>p\u6307\u5411\u4e0b\u4e00\u4e2a\u7ed3\u70b9\u3002<\/li>\n\n\n\n<li>\u8ba1\u6570\u5668 j \u76f8\u5e94\u52a01\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u2462\u9000\u51fa\u5faa\u73af\u65f6\u3002\u5982\u679c\u6307\u9488p\u4e3a\u7a7a\uff0c\u6216\u8005\u8ba1\u6570\u5668 j \u5927\u4e8e i \uff0c\u8bf4\u660e\u6307\u5b9a\u7684\u5e8f\u53f7 i \u503c\u4e0d\u5408\u6cd5\uff08i \u5927\u4e8e\u8868\u957fn\u6216\u8005\u5c0f\u4e8e\u7b49\u4e8e0\uff09\uff0c\u53d6\u503c\u5931\u8d25\u8fd4\u56deERROR\uff1b\u5426\u5219\u53d6\u503c\u6210\u529f\uff0c\u6b64\u65f6 j= i\u65f6\uff0cp\u6240\u6307\u7684\u7ed3\u70b9\u5c31\u662f\u8981\u627e\u7684\u7b2c i \u4e2a\u7ed3\u70b9\uff0c\u7528\u53c2\u6570 e \u4fdd\u5b58\u5f53\u524d\u8282\u70b9\u7684\u6570\u636e\u57df\uff0c\u8fd4\u56deOK\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int GetElem(LinkList L, int i, ElemType &amp;e) {\n\t\/\/\u5728\u5e26\u5934\u7ed3\u70b9\u7684\u5355\u94fe\u8868L\u4e2d\u6839\u636e\u5e8f\u53f7i\u83b7\u53d6\u5143\u7d20\u7684\u503c\uff0c\u7528e\u8fd4\u56deL\u4e2d\u7b2ci\u4e2a\u6570\u636e\u5143\u7d20\u7684\u503c\n\tLNode* p;\n\tp = L-&gt;next;  \/\/\u521d\u59cb\u5316\uff0cp\u6307\u5411\u9996\u5143\u7ed3\u70b9\uff0c\u8ba1\u6570\u5668j\u521d\u503c\u8d4b\u4e3a1\n\tint j = 1;\n\twhile (p &amp;&amp; j &lt; i) {\n\t\tp = p-&gt;next; \/\/p\u6307\u5411\u4e0b\u4e00\u4e2a\u8282\u70b9\n\t\tj++;         \/\/\u8ba1\u6570\u5668j\u76f8\u5e94\u52a01\n\t}\n\tif (!p || j &gt; i) { \/\/i\u503c\u4e0d\u5408\u6cd5i&gt;n\u6216\u22640\n\t\treturn ERROR;\n\t}\n\te = p-&gt;elem;     \/\/\u53d6\u7b2ci\u4e2a\u7ed3\u70b9\u7684\u6570\u636e\u57df\n\treturn OK;\n}<\/code><\/pre>\n\n\n\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6<\/strong>\uff1aO(n)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9700\u8981\u904d\u5386\u94fe\u8868\u76f4\u5230\u627e\u5230\u5339\u914d\u503c\u7684\u8282\u70b9\u6216\u5230\u8fbe\u94fe\u8868\u672b\u5c3e\uff0c\u6700\u574f\u60c5\u51b5\u4e0b\u662f O(n)\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u5355\u94fe\u8868\u7684\u67e5\u627e<\/h3>\n\n\n\n<p>\u5728\u94fe\u8868\u4e2d\u67e5\u627e\u7684\u65b9\u5f0f\u6709\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u901a\u8fc7\u5143\u7d20\u67e5\u627e\uff0c\u4e00\u79cd\u662f\u901a\u8fc7\u4f4d\u7f6e\u67e5\u627e<\/p>\n\n\n\n<p>\u54b1\u5148\u6765\u8bf4\u901a\u8fc7\u5143\u7d20\u67e5\u627e<\/p>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u7528\u6307\u9488p\u6307\u5411\u9996\u5143\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p>\u2461\u4ece\u9996\u5143\u7ed3\u70b9\u5f00\u59cb\u4f9d\u6b21\u987a\u7740\u94fe\u57dfnext\u5411\u4e0b\u67e5\u627e\uff0c\u53ea\u8981\u6307\u5411\u5f53\u524d\u7ed3\u70b9\u7684\u6307\u9488p\u4e0d\u4e3a\u7a7a\uff0c\u5e76\u4e14p\u6240\u6307\u7ed3\u70b9\u7684\u6570\u636e\u57df\u4e0d\u7b49\u4e8e\u7ed9\u5b9a\u503ce\uff0c\u5219\u5faa\u73af\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1ap\u6307\u5411\u4e0b\u4e00\u4e2a\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p>\u2462\u8fd4\u56dep\u3002\u82e5\u67e5\u627e\u6210\u529f\uff0cp\u6b64\u65f6\u6307\u5411\u7ed3\u70b9\u7684\u5730\u5740\u503c\uff0c\u82e5\u67e5\u627e\u5931\u8d25\uff0c\u5219p\u7684\u503c\u4e3aNULL\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LNode* LocateElem(LinkList L, ElemType e) {\n\t\/\/\u5728\u5e26\u5934\u7ed3\u70b9\u7684\u5355\u94fe\u8868L\u4e2d\u67e5\u627e\u503c\u4e3ae\u7684\u5143\u7d20\n\tLNode* p;\n\tp = L-&gt;next;  \/\/\u521d\u59cb\u5316\uff0cp\u6307\u5411\u9996\u5143\u7ed3\u70b9\n\twhile (p &amp;&amp; p-&gt;elem != e) {  \/\/\u987a\u94fe\u57df\u5411\u540e\u67e5\u627e\uff0c\u76f4\u5230p\u4e3a\u7a7a\u6216p\u6240\u6307\u7ed3\u70b9\u7684\u6570\u636e\u57df\u7b49\u4e8ee\n\t\tp = p-&gt;next; \/\/p\u6307\u5411\u4e0b\u4e00\u4e2a\u7ed3\u70b9\n\t}\n\treturn p;     \/\/\u67e5\u627e\u6210\u529f\u8fd4\u56de\u503c\u4e3ae\u7684\u7ed3\u70b9\u5730\u5740p\uff0c\u67e5\u627e\u5931\u8d25p\u4e3aNULL\n}<\/code><\/pre>\n\n\n\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6<\/strong>\uff1aO(n)\uff0c\u5176\u4e2d n \u662f\u94fe\u8868\u4e2d\u7684\u8282\u70b9\u6570\u91cf\u3002\u6700\u574f\u60c5\u51b5\u4e0b\u9700\u8981\u904d\u5386\u6574\u4e2a\u94fe\u8868\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u662f\u901a\u8fc7\u4f4d\u7f6e\u67e5\u627e<\/p>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u4ece\u5934\u7ed3\u70b9\u5f00\u59cb\u904d\u5386\u94fe\u8868\u3002<br>\u2461\u4f7f\u7528\u4e00\u4e2a\u8ba1\u6570\u5668\u6765\u8bb0\u5f55\u5f53\u524d\u8bbf\u95ee\u7684\u8282\u70b9\u4f4d\u7f6e\u3002<br>\u2462\u5f53\u8ba1\u6570\u5668\u8fbe\u5230\u76ee\u6807\u4f4d\u7f6e\u65f6\uff0c\u8fd4\u56de\u5f53\u524d\u8282\u70b9\u3002<br>\u2463\u5982\u679c\u904d\u5386\u5230\u94fe\u8868\u672b\u5c3e\u8fd8\u6ca1\u6709\u8fbe\u5230\u76ee\u6807\u4f4d\u7f6e\uff0c\u5219\u8fd4\u56de NULL\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LNode* LocateElem(LinkList L, int pos) {\n\tLNode* p = L; \/\/ \u4ece\u5934\u7ed3\u70b9\u5f00\u59cb\n\tint count = -1; \/\/ \u8ba1\u6570\u5668\uff0c\u4ece -1 \u5f00\u59cb\u662f\u56e0\u4e3a\u5934\u7ed3\u70b9\u4e0d\u5b58\u50a8\u6570\u636e\n\n\twhile (p != NULL &amp;&amp; count &lt; pos) {\n\t\tp = p-&gt;next;\n\t\tcount++;\n\t}\n\n\tif (p != NULL) {\n\t\treturn p; \/\/ \u627e\u5230\u4e86\u76ee\u6807\u4f4d\u7f6e\u7684\u8282\u70b9\n\t}\n\telse {\n\t\treturn NULL; \/\/ \u8d85\u51fa\u4e86\u94fe\u8868\u7684\u957f\u5ea6\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6<\/strong>\uff1aO(k+1)\uff0c\u5176\u4e2d k \u662f\u76ee\u6807\u4f4d\u7f6e\u3002\u6700\u597d\u7684\u60c5\u51b5\u662f k \u4e3a 0\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(1)\uff1b\u6700\u574f\u7684\u60c5\u51b5\u662f k \u4e3a n-1\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(n)\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5355\u94fe\u8868\u7684\u63d2\u5165<\/h3>\n\n\n\n<p>\u94fe\u8868\u7684\u63d2\u5165\u65b9\u5f0f\u4e0d\u540c\u4e8e\u987a\u5e8f\u8868\uff0c\u56e0\u4e3a\u94fe\u8868\u4e2d\u6bcf\u4e2a\u7ed3\u70b9\u7684\u6307\u9488\u57df\u90fd\u5b58\u50a8\u7740\u4e0b\u4e00\u4e2a\u7ed3\u70b9\u7684\u5730\u5740\uff0c\u6240\u4ee5\u8981\u5728\u4e24\u4e2a\u7ed3\u70b9\u4e4b\u95f4\u63d2\u5165\u4e00\u4e2a\u65b0\u7684\u7ed3\u70b9\uff0c\u9700\u8981\u4fee\u6539\u524d\u4e00\u4e2a\u7ed3\u70b9\u7684\u6307\u9488\u57df\u4ee5\u53ca\u63d2\u5165\u7ed3\u70b9\u7684\u6307\u9488\u57df\uff0c\u8fd9\u91cc\u6765\u4e00\u5f20\u56fe\u7247\u793a\u610f\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"301\" src=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726827398-\u5c4f\u5e55\u622a\u56fe-2024-09-20-181453-1024x301.png\" alt=\"\" class=\"wp-image-183\" srcset=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726827398-\u5c4f\u5e55\u622a\u56fe-2024-09-20-181453-1024x301.png 1024w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726827398-\u5c4f\u5e55\u622a\u56fe-2024-09-20-181453-300x88.png 300w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726827398-\u5c4f\u5e55\u622a\u56fe-2024-09-20-181453-768x226.png 768w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726827398-\u5c4f\u5e55\u622a\u56fe-2024-09-20-181453-1536x451.png 1536w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726827398-\u5c4f\u5e55\u622a\u56fe-2024-09-20-181453.png 1542w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u6839\u636e\u63d2\u5165\u64cd\u4f5c\u7684\u903b\u8f91\u5b9a\u4e49\uff0c\u6211\u4eec\u8981\u5148\u751f\u6210\u4e00\u4e2a\u6570\u636e\u57df\u4e3ax\u7684\u7ed3\u70b9\uff0c\u4e4b\u540e\u4fee\u6539\u7ed3\u70b9a\u4e2d\u7684\u6307\u9488\u57df\uff0c\u4ee4\u5176\u6307\u5411\u7ed3\u70b9x\uff0c\u800c\u7ed3\u70b9x\u4e2d\u7684\u6307\u9488\u57df\u5e94\u6307\u5411\u7ed3\u70b9b\uff0c\u4ece\u800c\u5b9e\u73b03\u4e2a\u5143\u7d20a\u3001b\u4ee5\u53cax\u4e4b\u95f4\u903b\u8f91\u5173\u7cfb\u7684\u53d8\u5316\u3002\u5047\u8bbes\u4e3a\u6307\u5411\u7ed3\u70b9x\u7684\u6307\u9488\uff0c\u5219\u4e0a\u8ff0\u6307\u9488\u4fee\u6539\u64cd\u4f5c\u7528\u8bed\u53e5\u63cf\u8ff0\u5373\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>s-&gt;next=p-&gt;next;\np-&gt;next=s;<\/code><\/pre>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u904d\u5386\u94fe\u8868\u76f4\u5230\u8fbe\u5230\u76ee\u6807\u4f4d\u7f6e\u7684\u524d\u4e00\u4e2a\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p>\u2461\u751f\u6210\u4e00\u4e2a\u65b0\u7ed3\u70b9*s\u3002<\/p>\n\n\n\n<p>\u2462\u5c06\u65b0\u7ed3\u70b9*s\u7684\u6570\u636e\u57df\u7f6e\u4e3ae\u3002<\/p>\n\n\n\n<p>\u2463\u5c06\u65b0\u7ed3\u70b9*s\u7684\u6307\u9488\u57df\u6307\u5411\u76ee\u6807\u4f4d\u7f6e\u7ed3\u70b9\u7684\u540e\u4e00\u4e2a\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p>\u2464\u5c06\u7ed3\u70b9*p\u7684\u6307\u9488\u57df\u6307\u5411\u65b0\u7ed3\u70b9*s\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int ListInsert(LinkList&amp; L, int i, ElemType e) {\n\t\/\/\u5728\u5e26\u5934\u7ed3\u70b9\u7684\u5355\u94fe\u8868L\u4e2d\u7b2ci\u4e2a\u4f4d\u7f6e\u63d2\u5165\u503c\u4e3ae\u7684\u65b0\u7ed3\u70b9\n\tLNode* p;\n        p=L;\n\tint j = 0;\n\twhile (p &amp;&amp; (j &lt; i - 1)) {\/\/\u67e5\u627e\u7b2ci-1\u4e2a\u7ed3\u70b9\uff0cp\u6307\u5411\u8be5\u7ed3\u70b9\n\t\tp = p-&gt;next;          \n\t\tj++;\n\t}\n\tif (!p || j &gt; i - 1) {\/\/i&gt;n+1\u6216\u8005i&lt;1\n\t\treturn ERROR;\n\t}\n\tLNode* s;\n\ts = new LNode;\/\/\u751f\u6210\u65b0\u7ed3\u70b9*s\n\ts-&gt;elem = e;\/\/\u5c06\u7ed3\u70b9*s\u7684\u6570\u636e\u57df\u7f6e\u4e3ae\n\ts-&gt;next = p-&gt;next;\/\/\u5c06\u7ed3\u70b9*s\u7684\u6307\u9488\u57df\u6307\u5411\u7ed3\u70b9\n\tp-&gt;next = s;\/\/\u5c06\u7ed3\u70b9*p\u7684\u6307\u9488\u57df\u6307\u5411\u7ed3\u70b9*s\n\treturn OK;\n}<\/code><\/pre>\n\n\n\n<p>\u548c\u987a\u5e8f\u8868\u4e00\u6837\uff0c\u5982\u679c\u8868\u4e2d\u6709n\u4e2a\u7ed3\u70b9\uff0c\u5219\u63d2\u5165\u64cd\u4f5c\u4e2d\u5408\u6cd5\u7684\u63d2\u5165\u4f4d\u7f6e\u6709n+1\u4e2a\uff0c\u53731\u2264i\u2264n+1\u3002\u5f53i=n+1\u65f6\uff0c\u65b0\u7ed3\u70b9\u5219\u63d2\u5728\u94fe\u8868\u5c3e\u90e8\u3002<\/p>\n\n\n\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6<\/strong>\uff1aO(k+1)\uff0c\u5176\u4e2d k \u662f\u76ee\u6807\u4f4d\u7f6e\u3002\u6700\u597d\u7684\u60c5\u51b5\u662f k \u4e3a 0\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(1)\uff1b\u6700\u574f\u7684\u60c5\u51b5\u662f k \u4e3a n-1\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(n)\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5355\u94fe\u8868\u7684\u5220\u9664<\/h3>\n\n\n\n<p> \u8981\u5220\u9664\u5355\u94fe\u8868\u4e2d\u6307\u5b9a\u4f4d\u7f6e\u7684\u5143\u7d20\uff0c\u540c\u63d2\u5165\u5143\u7d20\u4e00\u6837\uff0c\u9996\u5148\u5e94\u8be5\u627e\u5230\u8be5\u4f4d\u7f6e\u7684\u524d\u9a71\u7ed3\u70b9\u3002\u8fd9\u91cc\u76f4\u63a5\u4e0a\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1010\" height=\"322\" src=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726832491-\u5c4f\u5e55\u622a\u56fe-2024-09-20-193924.png\" alt=\"\" class=\"wp-image-185\" srcset=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726832491-\u5c4f\u5e55\u622a\u56fe-2024-09-20-193924.png 1010w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726832491-\u5c4f\u5e55\u622a\u56fe-2024-09-20-193924-300x96.png 300w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726832491-\u5c4f\u5e55\u622a\u56fe-2024-09-20-193924-768x245.png 768w\" sizes=\"(max-width: 1010px) 100vw, 1010px\" \/><\/figure>\n\n\n\n<p>\u5728\u5355\u94fe\u8868\u4e2d\u5220\u9664\u5143\u7d20b\u65f6\uff0c\u5e94\u8be5\u9996\u5148\u627e\u5230\u5176\u524d\u9a71\u7ed3\u70b9a\u3002\u4e3a\u4e86\u5728\u5355\u94fe\u8868\u4e2d\u5b9e\u73b0\u5143\u7d20a\u3001b\u4ee5\u53cac\u4e4b\u95f4\u903b\u8f91\u5173\u7cfb\u7684\u53d8\u5316\uff0c\u4ec5\u9700\u4fee\u6539\u7ed3\u70b9\u4e2da\u7684\u6307\u9488\u57df\u5373\u53ef\u3002\u5047\u8bbep\u4e3a\u6307\u5411\u7ed3\u70b9a\u7684\u6307\u9488\uff0c\u5219\u4fee\u6539\u8bed\u53e5\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p-&gt;next=p-&gt;next-&gt;next;<\/code><\/pre>\n\n\n\n<p>\u5728\u5220\u9664\u7ed3\u70b9b\u65f6\uff0c\u9664\u4e86\u4fee\u6539\u7ed3\u70b9a\u7684\u6307\u9488\u57df\u5916\uff0c\u8fd8\u8981\u91ca\u653e\u7ed3\u70b9b\u6240\u5360\u7684\u7a7a\u95f4\uff0c\u6240\u4ee5\u5728\u4fee\u6539\u6307\u9488\u524d\uff0c\u5e94\u8be5\u5f15\u5165\u53e6\u4e00\u4e2a\u6307\u9488q\uff0c\u4e34\u65f6\u4fdd\u5b58\u7ed3\u70b9b\u7684\u5730\u5740\u4ee5\u5907\u91ca\u653e\u3002<\/p>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u67e5\u627e\u8981\u5220\u9664\u7684\u7ed3\u70b9\u7684\u524d\u9a71\u7ed3\u70b9\uff0c\u5e76\u7531\u6307\u9488p\u6307\u5411\u8be5\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p>\u2461\u4e34\u65f6\u4fdd\u5b58\u5f85\u5220\u9664\u7684\u7ed3\u70b9\u7684\u5730\u5740\u5728q\u4e2d\uff0c\u4ee5\u5907\u91ca\u653e\u3002<\/p>\n\n\n\n<p>\u2462\u5c06\u7ed3\u70b9*p\u7684\u6307\u9488\u57df\u6307\u5411\u7684\u5220\u9664\u7ed3\u70b9\u7684\u7684\u540e\u7ee7\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p>\u2463\u91ca\u653e\u7ed3\u70b9\u7684\u7a7a\u95f4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int ListDelete(LinkList&amp; L, int i) {\n\t\/\/\u5728\u5e26\u5934\u7ed3\u70b9\u7684\u5355\u94fe\u8868L\u4e2d\uff0c\u5220\u9664\u7b2ci\u4e2a\u5143\u7d20\n\tLNode* p;\n\tp = L;\n\tint j = 0;\n\twhile ((p-&gt;next) &amp;&amp; (j &lt; i - 1)) {\/\/\u67e5\u627e\u7b2ci-1\u4e2a\u7ed3\u70b9\uff0cp\u6307\u5411\u8be5\u7ed3\u70b9\n\t\tp = p-&gt;next;\n\t\tj++;\n\t}\n\tif (!(p-&gt;next) || (j &gt; i - 1)) {\/\/\u5f53i&gt;n\u6216i&lt;n\u65f6\uff0c\u5220\u9664\u4f4d\u7f6e\u4e0d\u5408\u7406\n\t\treturn ERROR;\n\t}\n\tLNode* q;\n\tq = p-&gt;next; \/\/\u4e34\u65f6\u4fdd\u5b58\u88ab\u5220\u7ed3\u70b9\u7684\u5730\u5740\u4ee5\u5907\u91ca\u653e\n\tp-&gt;next = q-&gt;next;\/\/\u6539\u53d8\u5220\u9664\u8282\u70b9\u524d\u9a71\u7ed3\u70b9\u7684\u6307\u9488\u57df\n\tdelete q;\/\/\u91ca\u653e\u5220\u9664\u7ed3\u70b9\u7684\u7a7a\u95f4\n\treturn OK;\n}<\/code><\/pre>\n\n\n\n<p>\u5220\u9664\u7b97\u6cd5\u4e2d\u7684\u5faa\u73af\u6761\u4ef6\uff08p-&gt;next&amp;&amp;j&lt;i-1\uff09\u548c\u63d2\u5165\u7b97\u6cd5\u4e2d\u7684\u5faa\u73af\u6761\u4ef6\uff08p&amp;&amp;(j&lt;i-1)\uff09\u662f\u6709\u533a\u522b\u7684\u3002\u56e0\u4e3a\u63d2\u5165\u65f6\u7684\u6709\u6548\u7684\u4f4d\u7f6e\u4e3an+1\u4e2a\uff0c\u800c\u5220\u9664\u65f6\u7684\u6709\u6548\u4f4d\u7f6e\u53ea\u6709n\u4e2a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u521b\u5efa\u5355\u94fe\u8868<\/h3>\n\n\n\n<p>\u521b\u5efa\u5355\u94fe\u8868\u7c7b\u4f3c\u4e8e\u63d2\u5165\u7b97\u6cd5\uff0c\u6839\u636e\u7ed3\u70b9\u63d2\u5165\u4f4d\u7f6e\u7684\u4e0d\u540c\u5206\u4e3a\u524d\u63d2\u6cd5\u548c\u540e\u63d2\u6cd5\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u524d\u63d2\u6cd5\u521b\u5efa\u5355\u94fe\u8868<\/h4>\n\n\n\n<p>\u8fd9\u91cc\u76f4\u63a5\u653e\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"400\" src=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726840247-\u5c4f\u5e55\u622a\u56fe-2024-09-20-213537-1024x400.png\" alt=\"\" class=\"wp-image-188\" srcset=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726840247-\u5c4f\u5e55\u622a\u56fe-2024-09-20-213537-1024x400.png 1024w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726840247-\u5c4f\u5e55\u622a\u56fe-2024-09-20-213537-300x117.png 300w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726840247-\u5c4f\u5e55\u622a\u56fe-2024-09-20-213537-768x300.png 768w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726840247-\u5c4f\u5e55\u622a\u56fe-2024-09-20-213537-1536x600.png 1536w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726840247-\u5c4f\u5e55\u622a\u56fe-2024-09-20-213537.png 1768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u524d\u63d2\u6cd5\u662f\u901a\u8fc7\u5c06\u65b0\u7684\u7ed3\u70b9\u9010\u4e2a\u63d2\u5165\u94fe\u8868\u7684\u5934\u90e8\u5373\u5934\u7ed3\u70b9\u4e4b\u540e\u6765\u521b\u5efa\u94fe\u8868\uff0c\u6bcf\u6b21\u7533\u8bf7\u4e00\u4e2a\u65b0\u7684\u7ed3\u70b9\uff0c\u8bfb\u5165\u76f8\u5e94\u7684\u6570\u636e\u5143\u7d20\u503c\uff0c\u7136\u540e\u5c06\u65b0\u7ed3\u70b9\u63d2\u5165\u5230\u5934\u7ed3\u70b9\u4e4b\u540e\u3002<\/p>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u521b\u5efa\u4e00\u4e2a\u53ea\u6709\u5934\u7ed3\u70b9\u7684\u7a7a\u94fe\u8868\u3002<\/p>\n\n\n\n<p>\u2461\u6839\u636e\u521b\u5efa\u94fe\u8868\u5305\u62ec\u7684\u5143\u7d20\u4e2a\u6570n\uff0c\u5faa\u73afn\u6b21\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u751f\u6210\u4e00\u4e2a\u65b0\u7ed3\u70b9*p\uff1b<\/li>\n\n\n\n<li>\u8f93\u5165\u5143\u7d20\u8d4b\u7ed9\u65b0\u7ed3\u70b9*p\u7684\u6570\u636e\u57df\uff1b<\/li>\n\n\n\n<li>\u5c06\u65b0\u7ed3\u70b9*p\u63d2\u5165\u5230\u5934\u7ed3\u70b9\u4e4b\u540e\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>void CreateList_H(LinkList&amp; L, int n) {\n\tL = new LNode;\n\tL-&gt;next = NULL;\n\tLNode* p;\n\tfor (int i = 0; i &lt; n; i++) {\n\t\tp = new LNode;\n\t\tcin &gt;&gt; p-&gt;elem.no;\n\t\tp-&gt;next = L-&gt;next;\n\t\tL-&gt;next = p;\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6<\/strong>\uff1aO\uff08n\uff09\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u540e\u63d2\u6cd5\u521b\u5efa\u5355\u94fe\u8868<\/h4>\n\n\n\n<p>\u8fd9\u91cc\u4f9d\u65e7\u662f\u76f4\u63a5\u653e\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"2560\" height=\"1039\" src=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726892676-b72d1248-1904-44e8-9989-a95c82ea2936-edited-scaled.jpg\" alt=\"\" class=\"wp-image-191\" srcset=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726892676-b72d1248-1904-44e8-9989-a95c82ea2936-edited-scaled.jpg 2560w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726892676-b72d1248-1904-44e8-9989-a95c82ea2936-edited-300x122.jpg 300w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726892676-b72d1248-1904-44e8-9989-a95c82ea2936-edited-1024x416.jpg 1024w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726892676-b72d1248-1904-44e8-9989-a95c82ea2936-edited-768x312.jpg 768w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726892676-b72d1248-1904-44e8-9989-a95c82ea2936-edited-1536x623.jpg 1536w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726892676-b72d1248-1904-44e8-9989-a95c82ea2936-edited-2048x831.jpg 2048w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><\/figure>\n\n\n\n<p>\u662f\u4e0d\u662f\u975e\u5e38\u4e00\u76ee\u4e86\u7136\u3002\u540e\u63d2\u6cd5\u5c31\u662f\u901a\u8fc7\u5c06\u65b0\u7ed3\u70b9\u9010\u4e2a\u63d2\u5165\u94fe\u8868\u5c3e\u90e8\u6765\u521b\u5efa\u94fe\u8868\u3002\u548c\u524d\u63d2\u6cd5\u4e00\u6837\uff0c\u6bcf\u6b21\u7533\u8bf7\u4e00\u4e2a\u65b0\u7ed3\u70b9\uff0c\u8bfb\u5165\u76f8\u5e94\u7684\u6570\u636e\u5143\u7d20\u503c\u3002\u4e0d\u540c\u7684\u662f\uff0c\u4e3a\u4e86\u4f7f\u65b0\u7ed3\u70b9\u80fd\u591f\u63d2\u5165\u8868\u5c3e\uff0c\u9700\u8981\u589e\u52a0\u4e00\u4e2a\u5c3e\u6307\u9488\u6307\u5411\u94fe\u8868\u7684\u5c3e\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u521b\u5efa\u4e00\u4e2a\u53ea\u6709\u5934\u7ed3\u70b9\u7684\u7a7a\u94fe\u8868\u3002<\/p>\n\n\n\n<p>\u2461\u5c3e\u6307\u9488r\u521d\u59cb\u5316\uff0c\u6307\u5411\u5934\u8282\u70b9\u3002<\/p>\n\n\n\n<p>\u2462\u6839\u636e\u521b\u5efa\u94fe\u8868\u5305\u62ec\u7684\u5143\u7d20\u4e2a\u6570n\uff0c\u5faa\u73afn\u6b21\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u751f\u6210\u4e00\u4e2a\u65b0\u7ed3\u70b9*p\uff1b<\/li>\n\n\n\n<li>\u8f93\u5165\u5143\u7d20\u503c\u8d4b\u7ed9\u65b0\u7ed3\u70b9*p\u7684\u6570\u636e\u57df\uff1b<\/li>\n\n\n\n<li>\u5c06\u65b0\u7ed3\u70b9*p\u63d2\u5165\u5c3e\u7ed3\u70b9*r\u4e4b\u540e\uff1b<\/li>\n\n\n\n<li>\u5c3e\u6307\u9488r\u6307\u5411\u65b0\u7684\u5c3e\u7ed3\u70b9*p\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>void CreateList_B(LinkList&amp; L, int n) {\n\t\/\/\u6b63\u4f4d\u5e8f\u8f93\u5165n\u4e2a\u5143\u7d20\u7684\u503c\uff0c\u5efa\u7acb\u5e26\u8868\u5934\u8282\u70b9\u7684\u5355\u94fe\u8868L\n\tL = new LNode;\n\tL-&gt;next = NULL;\n\tLNode* r;\n\tr = L;\n\tLNode* p;\n\tfor (int i = 0; i &lt; n; i++) {\n\t\tp = new LNode;\n\t\tcin &gt;&gt; p-&gt;elem.no;\n\t\tp-&gt;next = NULL;\n\t\tr-&gt;next = p;\n\t\tr = p;\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6<\/strong>\uff1aO\uff08n\uff09\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6253\u5370\u5355\u94fe\u8868<\/h3>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u7684\u6307\u9488\u53d8\u91cftemp\uff0c\u5e76\u5c06\u5b83\u6307\u5411\u94fe\u8868\u5934\u7ed3\u70b9\u7684\u4e0b\u4e00\u4e2a\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p>\u2461\u4f7f\u7528\u4e00\u4e2awhile\u6765\u5faa\u73af\u904d\u5386\u94fe\u8868\u3002\u5faa\u73af\u7684\u6761\u4ef6\u4e3atemp\u4e0d\u7b49\u4e8eNULL\uff0c\u610f\u5473\u7740\u8fd8\u6ca1\u6709\u5230\u8fbe\u94fe\u8868\u7684\u8868\u5c3e\u3002<\/p>\n\n\n\n<p>\u2462\u6253\u5370\u5f53\u524d\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void PrintList(LinkList L) {\n\tLinkList temp = L-&gt;next; \/\/ \u4ece\u5934\u7ed3\u70b9\u7684next\u5f00\u59cb\u6253\u5370\n\twhile (temp != NULL) {\n\t\tprintf(\"%d \", temp-&gt;elem);\n\t\ttemp = temp-&gt;next;\n\t}\n\tprintf(\"\\n\");\n}<\/code><\/pre>\n\n\n\n<p>\u8865\u5145\u4e00\u4e3a\u4ec0\u4e48\u8981\u7528\u4e00\u4e2a\u4e34\u65f6\u6307\u9488\u53d8\u91cftemp\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4fdd\u62a4\u539f\u59cb\u94fe\u8868\u7ed3\u6784<\/strong>\uff1a\u5982\u679c\u4f60\u76f4\u63a5\u4f7f\u7528<code>L-&gt;next<\/code>\u4f5c\u4e3a\u5faa\u73af\u4e2d\u7684\u8fed\u4ee3\u5668\uff0c\u90a3\u4e48\u5728\u5faa\u73af\u8fc7\u7a0b\u4e2d\u4f60\u4f1a\u4e0d\u65ad\u5730\u6539\u53d8<code>L-&gt;next<\/code>\u7684\u503c\u3002\u4e00\u65e6\u4f60\u904d\u5386\u5230\u4e86\u94fe\u8868\u7684\u672b\u5c3e\uff0c<code>L-&gt;next<\/code>\u5c31\u4f1a\u6307\u5411<code>NULL<\/code>\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u4f60\u4e22\u5931\u4e86\u94fe\u8868\u7684\u8d77\u59cb\u4f4d\u7f6e\uff0c\u5373\u65e0\u6cd5\u518d\u8bbf\u95ee\u5230\u94fe\u8868\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u3002<\/li>\n\n\n\n<li><strong>\u907f\u514d\u4fee\u6539\u8f93\u5165\u53c2\u6570<\/strong>\uff1a\u51fd\u6570\u63a5\u6536\u7684\u662f\u94fe\u8868\u7684\u5934\u7ed3\u70b9<code>L<\/code>\u3002\u5982\u679c\u76f4\u63a5\u64cd\u4f5c<code>L<\/code>\u6216<code>L-&gt;next<\/code>\uff0c\u90a3\u4e48\u5728\u51fd\u6570\u5916\u90e8\u8c03\u7528\u8005\u53ef\u80fd\u4f1a\u770b\u5230\u94fe\u8868\u5934\u88ab\u4fee\u6539\u4e86\uff0c\u8fd9\u662f\u4e0d\u5e0c\u671b\u53d1\u751f\u7684\u60c5\u51b5\u3002\u4f7f\u7528<code>temp<\/code>\u53ef\u4ee5\u5728\u4e0d\u5f71\u54cd\u539f\u94fe\u8868\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u904d\u5386\u3002<\/li>\n\n\n\n<li><strong>\u4fdd\u6301\u4ee3\u7801\u6e05\u6670\u548c\u53ef\u8bfb\u6027<\/strong>\uff1a\u901a\u8fc7\u5f15\u5165\u4e00\u4e2a\u4e34\u65f6\u53d8\u91cf<code>temp<\/code>\u6765\u904d\u5386\u94fe\u8868\uff0c\u53ef\u4ee5\u4f7f\u4ee3\u7801\u903b\u8f91\u66f4\u52a0\u6e05\u6670\uff0c\u66f4\u5bb9\u6613\u7406\u89e3\u3002\u5b83\u6e05\u695a\u5730\u8868\u660e\u4e86\u4f60\u7684\u610f\u56fe\u662f\u904d\u5386\u6574\u4e2a\u94fe\u8868\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u64cd\u4f5c\u94fe\u8868\u7684\u5934\u90e8\u3002<\/li>\n\n\n\n<li><strong>\u4fbf\u4e8e\u8c03\u8bd5\u548c\u7ef4\u62a4<\/strong>\uff1a\u5982\u679c\u5728\u672a\u6765\u4f60\u9700\u8981\u5bf9\u8fd9\u4e2a\u51fd\u6570\u8fdb\u884c\u8c03\u8bd5\u6216\u8005\u4fee\u6539\uff0c\u6709\u4e00\u4e2a\u660e\u786e\u7684\u904d\u5386\u6307\u9488\u4f1a\u4f7f\u5f97\u5de5\u4f5c\u53d8\u5f97\u66f4\u52a0\u7b80\u5355\u3002\u4f60\u53ef\u4ee5\u8f7b\u677e\u5730\u8bbe\u7f6e\u65ad\u70b9\u6765\u68c0\u67e5\u5f53\u524d\u904d\u5386\u7684\u4f4d\u7f6e\uff0c\u800c\u4e0d\u7528\u62c5\u5fc3\u5f71\u54cd\u94fe\u8868\u672c\u8eab\u7684\u72b6\u6001\u3002<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u8865\u5145<\/h2>\n\n\n\n<p>\u8fd9\u91cc\u8865\u5145\u4e00\u70b9\uff0c\u524d\u9762\u6211\u4eec\u8bb2\u4e86\u5355\u94fe\u8868\u7684\u5b58\u50a8\u7ed3\u6784\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>typedef struct LNode {\n\tElemType elem;     \n\tstruct LNode* next;\n}LNode, * LinkList;        <\/code><\/pre>\n\n\n\n<p>\u806a\u660e\u7684\u4f60\u770b\u5230\u6570\u636e\u57dfElemType elem\uff0c\u80af\u5b9a\u5c31\u4f1a\u8054\u60f3\u5230\u4e0a\u4e00\u7bc7\u6587\u7ae0\u987a\u5e8f\u8868\u4e2d\u7684ElemType *elem\uff0c\u8fd9\u4e2aElemType\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ecstruct\uff0c\u4e00\u822c\u6765\u8bf4\uff0c\u6211\u4eec\u8981\u5b9a\u4e49\u4e00\u4e2a\u4e66\u7684\u5355\u94fe\u8868\uff0c\u6211\u4eec\u4f1a\u5148\u5b9a\u4e49\u4e00\u4e2a\u4e66\u7684\u7ed3\u6784\u4f53\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>typedef struct {\n\tchar no&#91;50];\/\/\u4e66\u7684\u6807\u53f7\n\tchar title&#91;50];\/\/\u4e66\u7684\u4e66\u540d\n\tfloat price;\/\/\u4e66\u7684\u4ef7\u683c\n}Book;<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u5728\u7528\u4e66\u7684\u7ed3\u6784\u4f53\u4ee3\u66ffElemType<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>typedef struct LNode {\n\tBook elem;     \n\tstruct LNode* next;\n}LNode, * LinkList; <\/code><\/pre>\n\n\n\n<p>\u8fd9\u79cd\u5f62\u5f0f\u4e00\u822c\u662f\u6211\u4eec\u5e38\u7528\u7684\u5f62\u5f0f\uff0c\u5176\u6570\u636e\u57df\u662fBook\u8fd9\u4e2a\u7ed3\u6784\u4f53\uff0c\u8fd8\u6709\u4e00\u79cd\u5b9a\u4e49\u4e66\u7684\u4fe1\u606f\u7684\u5355\u94fe\u8868\u7684\u5f62\u5f0f\uff0c\u5c31\u662f\u628a\u4e66\u7684\u4fe1\u606f\u5f53\u4f5c\u6570\u636e\u57df\uff0c\u5e76\u4e14\u5b83\u81ea\u8eab\u53ef\u4ee5\u5f62\u6210\u4e00\u4e2a\u94fe\u8868\u8282\u70b9\u3002\uff0c\u5177\u4f53\u5f62\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>typedef struct{\nchar no&#91;50];\nchar title&#91;50];\nstruct Book *next;\n}Book,*LBook;<\/code><\/pre>\n\n\n\n<p>\u8bf4\u4e00\u4e0b\u5b83\u4fe9\u7684\u533a\u522b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6570\u636e\u4e0e\u7ed3\u6784<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u7b2c\u4e00\u79cd&nbsp;<code>Book<\/code>&nbsp;\u7ed3\u6784\u4f53<\/strong>\uff1a\u65e2\u662f\u6570\u636e\u5bb9\u5668\u4e5f\u662f\u94fe\u8868\u8282\u70b9\uff0c\u56e0\u4e3a\u5b83\u5305\u542b\u4e86\u6570\u636e\u548c\u6307\u9488\u3002<\/li>\n\n\n\n<li><strong><code>LNode<\/code>&nbsp;\u7ed3\u6784\u4f53<\/strong>\uff1a\u662f\u94fe\u8868\u8282\u70b9\uff0c\u5305\u542b\u4e86\u4e00\u4e2a&nbsp;<code>Book<\/code>&nbsp;\u6570\u636e\u9879\u548c\u4e00\u4e2a\u6307\u5411\u4e0b\u4e00\u4e2a\u8282\u70b9\u7684\u6307\u9488\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u529f\u80fd<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u7b2c\u4e00\u79cd&nbsp;<code>Book<\/code>&nbsp;\u7ed3\u6784\u4f53<\/strong>\uff1a\u53ef\u4ee5\u76f4\u63a5\u7528\u4e8e\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u94fe\u8868\uff0c\u6bcf\u4e2a\u8282\u70b9\u90fd\u662f\u4e00\u4e2a&nbsp;<code>Book<\/code>&nbsp;\u5b9e\u4f8b\u3002<\/li>\n\n\n\n<li><strong><code>LNode<\/code>&nbsp;\u7ed3\u6784\u4f53<\/strong>\uff1a\u7528\u4e8e\u6784\u5efa\u4e00\u4e2a\u66f4\u590d\u6742\u7684\u94fe\u8868\uff0c\u6bcf\u4e2a\u8282\u70b9\u5305\u542b\u4e00\u4e2a\u5b8c\u6574\u7684&nbsp;<code>Book<\/code>&nbsp;\u5b9e\u4f8b\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u5185\u5b58\u5e03\u5c40<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u7b2c\u4e00\u79cd&nbsp;<code>Book<\/code>&nbsp;\u7ed3\u6784\u4f53<\/strong>\uff1a\u5305\u542b\u4e09\u4e2a\u5b57\u6bb5\uff1a\u4e66\u53f7\u3001\u4e66\u540d\u548c\u6307\u5411\u4e0b\u4e00\u4e2a&nbsp;<code>Book<\/code>&nbsp;\u7684\u6307\u9488\u3002<\/li>\n\n\n\n<li><strong><code>LNode<\/code>&nbsp;\u7ed3\u6784\u4f53<\/strong>\uff1a\u5305\u542b\u4e24\u4e2a\u5b57\u6bb5\uff1a\u4e00\u4e2a&nbsp;<code>Book<\/code>&nbsp;\u5b9e\u4f8b\u548c\u4e00\u4e2a\u6307\u5411\u4e0b\u4e00\u4e2a&nbsp;<code>LNode<\/code>&nbsp;\u7684\u6307\u9488\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u4f7f\u7528\u573a\u666f<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u7b2c\u4e00\u79cd&nbsp;<code>Book<\/code>&nbsp;\u7ed3\u6784\u4f53<\/strong>\uff1a\u5f53\u4f60\u9700\u8981\u4e00\u4e2a\u7b80\u5355\u7684\u94fe\u8868\u6765\u5b58\u50a8\u4e66\u7c4d\u4fe1\u606f\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u8fd9\u79cd\u7ed3\u6784\u4f53\u3002<\/li>\n\n\n\n<li><strong><code>LNode<\/code>&nbsp;\u7ed3\u6784\u4f53<\/strong>\uff1a\u5f53\u4f60\u9700\u8981\u4e00\u4e2a\u66f4\u590d\u6742\u7684\u94fe\u8868\u7ed3\u6784\uff0c\u6bcf\u4e2a\u8282\u70b9\u5305\u542b\u4e00\u4e2a\u5b8c\u6574\u7684&nbsp;<code>Book<\/code>&nbsp;\u5b9e\u4f8b\u65f6\uff0c\u5e94\u8be5\u4f7f\u7528\u8fd9\u79cd\u7ed3\u6784\u4f53\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>\u7b80\u800c\u8a00\u4e4b\uff0c\u7b2c\u4e00\u79cd <code>Book<\/code> \u7ed3\u6784\u4f53\u53ef\u4ee5\u5355\u72ec\u5f62\u6210\u4e00\u4e2a\u7b80\u5355\u7684\u94fe\u8868\uff0c\u800c <code>LNode<\/code> \u7ed3\u6784\u4f53\u5219\u66f4\u9002\u5408\u6784\u5efa\u4e00\u4e2a\u66f4\u590d\u6742\u3001\u66f4\u7075\u6d3b\u7684\u94fe\u8868\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5faa\u73af\u94fe\u8868<\/h2>\n\n\n\n<p>\u5faa\u73af\u94fe\u8868\u662f\u53e6\u4e00\u79cd\u5f62\u5f0f\u7684\u94fe\u5f0f\u5b58\u50a8\u7ed3\u6784\u3002\u8bf4\u662f\u53e6\u4e00\u79cd\u5f62\u5f0f\uff0c\u4f46\u5b9e\u9645\u4e0a\u5c31\u662f\u5355\u94fe\u8868\u6700\u540e\u4e00\u4e2a\u7ed3\u70b9\u7684\u6307\u9488\u57df\u6307\u5411\u5934\u7ed3\u70b9\uff0c\u5f62\u6210\u4e00\u4e2a\u73af\u3002\u56e0\u6b64\uff0c\u4ece\u8868\u4e2d\u4efb\u610f\u4e00\u4e2a\u7ed3\u70b9\u51fa\u53d1\u90fd\u53ef\u4ee5\u627e\u5230\u8868\u4e2d\u7684\u5176\u5b83\u7ed3\u70b9\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"465\" src=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726901716-b18f571b-d511-4419-b79e-c28d81eb465e-1024x465.jpg\" alt=\"\" class=\"wp-image-193\" srcset=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726901716-b18f571b-d511-4419-b79e-c28d81eb465e-1024x465.jpg 1024w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726901716-b18f571b-d511-4419-b79e-c28d81eb465e-300x136.jpg 300w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726901716-b18f571b-d511-4419-b79e-c28d81eb465e-768x348.jpg 768w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726901716-b18f571b-d511-4419-b79e-c28d81eb465e-1536x697.jpg 1536w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1726901716-b18f571b-d511-4419-b79e-c28d81eb465e-2048x929.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5faa\u73af\u94fe\u8868\u7684\u64cd\u4f5c\u548c\u5355\u94fe\u8868\u57fa\u672c\u4e00\u81f4\uff0c\u5dee\u522b\u4ec5\u5728\u4e8e\uff1a\u5f53\u94fe\u8868\u8fdb\u884c\u904d\u5386\u65f6\uff0c\u5224\u522b\u5f53\u524d\u6307\u9488p\u662f\u5426\u6307\u5411\u8868\u5c3e\u7ed3\u70b9\u7684\u7ec8\u6b62\u6761\u4ef6\u4e0d\u540c\u3002\u5728\u5355\u94fe\u8868\u4e2d\uff0c\u5224\u522b\u6761\u4ef6\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p!=NULL\n\u6216\np-&gt;next!=NULL\n<\/code><\/pre>\n\n\n\n<p>\u800c\u5faa\u73af\u94fe\u8868\u7684\u5224\u522b\u6761\u4ef6\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>p!=L\n\u6216\np-&gt;next!=L<\/code><\/pre>\n\n\n\n<p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u82e5\u5728\u5faa\u73af\u94fe\u8868\u4e2d\u8bbe\u7acb\u5c3e\u6307\u9488\u800c\u4e0d\u8bbe\u5934\u6307\u9488\uff0c\u53ef\u4f7f\u4e00\u4e9b\u64cd\u4f5c\u7b80\u5316\u3002\u4f8b\u5982\uff0c\u4e24\u4e2a\u7ebf\u6027\u8868\u5408\u5e76\u6210\u4e00\u4e2a\u8868\u65f6\uff0c\u4ec5\u9700\u5c06\u7b2c\u4e00\u4e2a\u8868\u7684\u5c3e\u6307\u9488\u6307\u5411\u7b2c\u4e8c\u4e2a\u8868\u7684\u7b2c\u4e00\u4e2a\u7ed3\u70b9\uff0c\u7b2c\u4e8c\u4e2a\u8868\u7684\u5c3e\u6307\u9488\u6307\u5411\u7b2c\u4e00\u4e2a\u8868\u7684\u5934\u7ed3\u70b9\uff0c\u7136\u540e\u91ca\u653e\u7b2c\u4e8c\u4e2a\u8868\u7684\u5934\u7ed3\u70b9\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8865\u5145<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u8282\u70b9(Node)<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u6bcf\u4e2a\u8282\u70b9\u81f3\u5c11\u5305\u542b\u4e24\u4e2a\u90e8\u5206\uff1a\u5b58\u50a8\u7684\u6570\u636e\u5143\u7d20\u548c\u4e00\u4e2a\u6307\u5411\u4e0b\u4e00\u4e2a\u8282\u70b9\u7684\u5f15\u7528\u3002<\/li>\n\n\n\n<li>\u5728\u5faa\u73af\u94fe\u8868\u4e2d\uff0c\u6bcf\u4e2a\u8282\u70b9\u7684\u201c\u4e0b\u4e00\u4e2a\u201d\u6307\u9488\u603b\u662f\u6307\u5411\u53e6\u4e00\u4e2a\u8282\u70b9\uff1b\u5373\u4f7f\u662f\u6700\u540e\u4e00\u4e2a\u8282\u70b9\u4e5f\u4e0d\u4f8b\u5916\uff0c\u5b83\u7684\u201c\u4e0b\u4e00\u4e2a\u201d\u6307\u9488\u5c06\u6307\u5411\u5934\u8282\u70b9\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u5934\u8282\u70b9(Head Node)<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u901a\u5e38\u7528\u6765\u6807\u8bc6\u94fe\u8868\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002\u5728\u5faa\u73af\u94fe\u8868\u4e2d\uff0c\u5934\u8282\u70b9\u540c\u6837\u4f5c\u4e3a\u8bbf\u95ee\u6574\u4e2a\u94fe\u8868\u7684\u5165\u53e3\u70b9\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u94fe\u8868\u4e3a\u7a7a\uff0c\u5219\u5934\u8282\u70b9\u53ef\u80fd\u4e3a&nbsp;<code>null<\/code>&nbsp;\u6216\u6307\u5411\u81ea\u8eab\u5f62\u6210\u81ea\u73af\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u5c3e\u8282\u70b9(Tail Node)<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u5c3e\u8282\u70b9\u662f\u94fe\u8868\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u8282\u70b9\uff0c\u5728\u666e\u901a\u94fe\u8868\u4e2d\u5b83\u6307\u5411&nbsp;<code>null<\/code>\uff0c\u4f46\u5728\u5faa\u73af\u94fe\u8868\u4e2d\u5b83\u6307\u5411\u5934\u8282\u70b9\u3002<\/li>\n\n\n\n<li>\u7531\u4e8e\u5faa\u73af\u6027\u8d28\uff0c\u6709\u65f6\u5019\u6211\u4eec\u4e0d\u9700\u8981\u7279\u522b\u533a\u5206\u5934\u5c3e\u8282\u70b9\u6765\u5b9e\u73b0\u4e00\u4e9b\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u904d\u5386<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u904d\u5386\u5faa\u73af\u94fe\u8868\u65f6\u9700\u8981\u8bbe\u7f6e\u6761\u4ef6\u4ee5\u907f\u514d\u65e0\u9650\u5faa\u73af\u3002\u4e00\u79cd\u5e38\u89c1\u7684\u65b9\u6cd5\u662f\u4ece\u4efb\u610f\u8282\u70b9\u5f00\u59cb\u904d\u5386\uff0c\u5e76\u4e14\u8ddf\u8e2a\u5df2\u8bbf\u95ee\u8fc7\u7684\u8282\u70b9\u6570\u6216\u8005\u4f7f\u7528\u4e00\u4e2a\u989d\u5916\u7684\u6807\u5fd7\u4f4d\u6765\u5224\u65ad\u662f\u5426\u56de\u5230\u4e86\u8d77\u70b9\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u63d2\u5165\/\u5220\u9664<\/strong>:\n<ul class=\"wp-block-list\">\n<li>\u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c\u901a\u5e38\u6d89\u53ca\u5230\u66f4\u65b0\u76f8\u90bb\u8282\u70b9\u7684\u94fe\u63a5\u5173\u7cfb\uff0c\u786e\u4fdd\u5faa\u73af\u7279\u6027\u4e0d\u88ab\u7834\u574f\u3002<\/li>\n\n\n\n<li>\u7279\u522b\u5730\uff0c\u5728\u7a7a\u94fe\u8868\u4e2d\u63d2\u5165\u7b2c\u4e00\u4e2a\u8282\u70b9\u65f6\uff0c\u8fd9\u4e2a\u8282\u70b9\u540c\u65f6\u4f5c\u4e3a\u5934\u8282\u70b9\u548c\u5c3e\u8282\u70b9\uff0c\u5e76\u4e14\u5b83\u7684\u201c\u4e0b\u4e00\u4e2a\u201d\u6307\u9488\u5e94\u6307\u5411\u81ea\u5df1\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u53cc\u5411\u94fe\u8868<\/h2>\n\n\n\n<p>\u53cc\u5411\u94fe\u8868\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u7ebf\u6027\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u4e0e\u5355\u5411\u94fe\u8868\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u6bcf\u4e2a\u8282\u70b9\u4e0d\u4ec5\u5305\u542b\u6307\u5411\u4e0b\u4e00\u4e2a\u8282\u70b9\u7684\u6307\u9488\uff0c\u8fd8\u5305\u542b\u6307\u5411\u524d\u4e00\u4e2a\u8282\u70b9\u7684\u6307\u9488\u3002\u8fd9\u79cd\u8bbe\u8ba1\u4f7f\u5f97\u5728\u94fe\u8868\u4e2d\u65e2\u53ef\u4ee5\u5411\u524d\u904d\u5386\u4e5f\u53ef\u4ee5\u5411\u540e\u904d\u5386\uff0c\u540c\u65f6\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u7684\u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u5199\u4e00\u4e2a\u53cc\u5411\u94fe\u8868\u7684\u5b58\u50a8\u7ed3\u6784\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>typedef struct BuLNode {\n\tElemType elem;\n\tstruct DuLNode* prior;\/\/\u6307\u5411\u76f4\u63a5\u524d\u9a71\n\tstruct DuLNode* next;\/\/\u6307\u5411\u76f4\u63a5\u540e\u7ee7\n}DuLNode,*DuLinkList;<\/code><\/pre>\n\n\n\n<p>\u5728\u53cc\u5411\u94fe\u8868\u4e2d\u4ec5\u6709\u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c\u6709\u8f83\u5927\u7684\u533a\u522b<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u53cc\u5411\u94fe\u8868\u7684\u63d2\u5165<\/h3>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u68c0\u67e5\u4f4d\u7f6e\u7684\u5408\u6cd5\u6027\u3002\u5982\u679ci&lt;=0\uff0c\u5219\u63d2\u5165\u4f4d\u7f6e\u4e0d\u5408\u6cd5\uff0c\u8fd4\u56de\u9519\u8bef\u3002<\/p>\n\n\n\n<p>\u2461\u627e\u5230\u63d2\u5165\u4f4d\u7f6e\u7684\u524d\u9a71\u7ed3\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u4e00\u4e2a\u6307\u9488&nbsp;<code>p<\/code>&nbsp;\u4ece\u5934\u7ed3\u70b9\u5f00\u59cb\u904d\u5386\uff0c\u76f4\u5230\u627e\u5230\u7b2c&nbsp;<code>i-1<\/code>&nbsp;\u4e2a\u8282\u70b9\uff08\u5373\u8981\u63d2\u5165\u4f4d\u7f6e\u7684\u524d\u9a71\u8282\u70b9\uff09\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u5728\u904d\u5386\u8fc7\u7a0b\u4e2d\u53d1\u73b0&nbsp;<code>p<\/code>&nbsp;\u4e3a\u7a7a\u6216\u8005\u904d\u5386\u6b21\u6570\u8d85\u8fc7&nbsp;<code>i-1<\/code>\uff0c\u8bf4\u660e\u4f4d\u7f6e\u8d85\u51fa\u94fe\u8868\u8303\u56f4\uff0c\u8fd4\u56de\u9519\u8bef\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u2462\u521b\u5efa\u65b0\u8282\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u52a8\u6001\u5206\u914d\u4e00\u4e2a\u65b0\u7684\u8282\u70b9&nbsp;<code>s<\/code>&nbsp;\u5e76\u8bbe\u7f6e\u5176\u6570\u636e\u57df&nbsp;<code>elem<\/code>&nbsp;\u4e3a&nbsp;<code>e<\/code>\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u5185\u5b58\u5206\u914d\u5931\u8d25\uff0c\u8fd4\u56de\u9519\u8bef\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u2463\u66f4\u65b0\u6307\u9488\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c06\u65b0\u8282\u70b9&nbsp;<code>s<\/code>&nbsp;\u7684&nbsp;<code>next<\/code>&nbsp;\u6307\u9488\u6307\u5411\u539f\u7b2c&nbsp;<code>i<\/code>&nbsp;\u4e2a\u8282\u70b9\uff08\u5373&nbsp;<code>p-&gt;next<\/code>\uff09\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u539f\u7b2c&nbsp;<code>i<\/code>&nbsp;\u4e2a\u8282\u70b9\u5b58\u5728\uff0c\u5219\u5c06\u5176&nbsp;<code>prev<\/code>&nbsp;\u6307\u9488\u6307\u5411\u65b0\u8282\u70b9&nbsp;<code>s<\/code>\u3002<\/li>\n\n\n\n<li>\u5c06\u65b0\u8282\u70b9&nbsp;<code>s<\/code>&nbsp;\u7684&nbsp;<code>prev<\/code>&nbsp;\u6307\u9488\u6307\u5411\u539f\u7b2c&nbsp;<code>i-1<\/code>&nbsp;\u4e2a\u8282\u70b9&nbsp;<code>p<\/code>\u3002<\/li>\n\n\n\n<li>\u5c06\u539f\u7b2c&nbsp;<code>i-1<\/code>&nbsp;\u4e2a\u8282\u70b9&nbsp;<code>p<\/code>&nbsp;\u7684&nbsp;<code>next<\/code>&nbsp;\u6307\u9488\u6307\u5411\u65b0\u8282\u70b9&nbsp;<code>s<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>int InsertDList(DLinkList&amp; L, int i, ElemType e) {\n\tif (i &lt;= 0) {\n\t\tcout &lt;&lt; \"\u4f4d\u7f6e\u5fc5\u987b\u5927\u4e8e0\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\tDNode* p = L;\n\tint j = 0;\n\twhile (p &amp;&amp; (j &lt; i - 1)) {\n\t\tp = p-&gt;next;\n\t\tj++;\n\t}\n\tif (!p || j &gt; i - 1) {\n\t\tcout &lt;&lt; \"\u8d85\u51fa\u94fe\u8868\u8303\u56f4\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\tDNode* s = new DNode;\n\tif (s == NULL) {\n\t\tcout &lt;&lt; \"\u5185\u5b58\u5206\u914d\u5931\u8d25\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\ts-&gt;elem = e;\n\ts-&gt;next = p-&gt;next;\n\tif (p-&gt;next) {\n\t\tp-&gt;next-&gt;prev = s;\n\t}\n\ts-&gt;prev = p;\n\tp-&gt;next = s;\n\treturn OK;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u53cc\u5411\u94fe\u8868\u7684\u5220\u9664<\/h3>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u627e\u5230\u8981\u5220\u9664\u7684\u7ed3\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u4e00\u4e2a\u6307\u9488&nbsp;<code>p<\/code>&nbsp;\u4ece\u5934\u7ed3\u70b9\u5f00\u59cb\u904d\u5386\uff0c\u76f4\u5230\u627e\u5230\u7b2c&nbsp;<code>i<\/code>&nbsp;\u4e2a\u8282\u70b9\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u5728\u904d\u5386\u8fc7\u7a0b\u4e2d\u53d1\u73b0&nbsp;<code>p<\/code>&nbsp;\u4e3a\u7a7a\u6216\u8005\u904d\u5386\u6b21\u6570\u8d85\u8fc7&nbsp;<code>i<\/code>\uff0c\u8bf4\u660e\u4f4d\u7f6e\u8d85\u51fa\u94fe\u8868\u8303\u56f4\uff0c\u8fd4\u56de\u9519\u8bef\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u2461\u4fdd\u5b58\u88ab\u5220\u9664\u8282\u70b9\u7684\u6570\u636e\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c06\u88ab\u5220\u9664\u8282\u70b9\u7684\u6570\u636e\u57df&nbsp;<code>p-&gt;elem<\/code>&nbsp;\u8d4b\u503c\u7ed9&nbsp;<code>e<\/code>\uff0c\u8fd9\u6837\u8c03\u7528\u8005\u53ef\u4ee5\u901a\u8fc7&nbsp;<code>e<\/code>&nbsp;\u83b7\u53d6\u5230\u88ab\u5220\u9664\u7684\u6570\u636e\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u2462\u66f4\u65b0\u6307\u9488\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u66f4\u65b0\u524d\u9a71\u8282\u70b9\u7684&nbsp;<code>next<\/code>&nbsp;\u6307\u9488\uff0c\u4f7f\u5176\u6307\u5411\u88ab\u5220\u9664\u8282\u70b9\u7684\u540e\u7ee7\u8282\u70b9\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u88ab\u5220\u9664\u8282\u70b9\u6709\u540e\u7ee7\u8282\u70b9\uff0c\u66f4\u65b0\u5176&nbsp;<code>prev<\/code>&nbsp;\u6307\u9488\uff0c\u4f7f\u5176\u6307\u5411\u524d\u9a71\u8282\u70b9\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u2463\u91ca\u653e\u5185\u5b58\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5220\u9664\u8282\u70b9\u540e\uff0c\u91ca\u653e\u8be5\u8282\u70b9\u6240\u5360\u7528\u7684\u5185\u5b58\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>int DeleteDList(DLinkList&amp; L, int i, ElemType&amp; e) {\n\tif (i &lt; 0) {\n\t\tcout &lt;&lt; \"\u4f4d\u7f6e\u5fc5\u987b\u5927\u4e8e0\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\tDNode* p = L;\n\tint j = 0;\n\twhile (p &amp;&amp; (j &lt; i)) {\n\t\tp = p-&gt;next;\n\t\tj++;\n\t}\n\tif (!p || j &gt; i) {\n\t\tcout &lt;&lt; \"\u4f4d\u7f6e\u8d85\u51fa\u8303\u56f4\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\te = p-&gt;elem;\n\tp-&gt;prev-&gt;next = p-&gt;next;\n\tif (p-&gt;next) {\n\t\tp-&gt;next-&gt;prev = p-&gt;prev;\n\t}\n\tdelete p;\n\treturn OK;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u548c\u94fe\u8868\u7684\u6bd4\u8f83<\/h2>\n\n\n\n<p>\u987a\u5e8f\u8868\uff08\u4e5f\u79f0\u4e3a\u6570\u7ec4\uff09\u548c\u94fe\u8868\u662f\u4e24\u79cd\u5e38\u89c1\u7684\u7ebf\u6027\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u4eec\u5728\u5b58\u50a8\u65b9\u5f0f\u3001\u8bbf\u95ee\u6548\u7387\u3001\u63d2\u5165\u5220\u9664\u64cd\u4f5c\u7b49\u65b9\u9762\u6709\u7740\u4e0d\u540c\u7684\u7279\u6027\u548c\u9002\u7528\u573a\u666f\u3002\u4e0b\u9762\u4ece\u7a7a\u95f4\u548c\u65f6\u95f4\u590d\u6742\u5ea6\u7b49\u591a\u4e2a\u65b9\u9762\u5bf9\u8fd9\u4e24\u79cd\u6570\u636e\u7ed3\u6784\u8fdb\u884c\u8be6\u7ec6\u6bd4\u8f83\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7a7a\u95f4\u4f7f\u7528<\/h3>\n\n\n\n<p><strong>\u987a\u5e8f\u8868:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f18\u70b9\uff1a\u7531\u4e8e\u6240\u6709\u5143\u7d20\u8fde\u7eed\u5b58\u50a8\uff0c\u4e0d\u9700\u8981\u989d\u5916\u7684\u6307\u9488\u6216\u5f15\u7528\u4fe1\u606f\uff0c\u56e0\u6b64\u5bf9\u4e8e\u76f8\u540c\u6570\u91cf\u7684\u6570\u636e\uff0c\u987a\u5e8f\u8868\u901a\u5e38\u5360\u7528\u66f4\u5c11\u7684\u7a7a\u95f4\u3002<\/li>\n\n\n\n<li>\u7f3a\u70b9\uff1a\u9700\u8981\u9884\u5148\u5206\u914d\u8db3\u591f\u7684\u5185\u5b58\u7a7a\u95f4\u3002\u5982\u679c\u5b9e\u9645\u4f7f\u7528\u7684\u7a7a\u95f4\u5c0f\u4e8e\u5206\u914d\u7684\u7a7a\u95f4\uff0c\u5219\u4f1a\u9020\u6210\u6d6a\u8d39\uff1b\u53cd\u4e4b\uff0c\u5982\u679c\u5b9e\u9645\u9700\u6c42\u8d85\u8fc7\u5206\u914d\u7684\u7a7a\u95f4\uff0c\u5219\u9700\u8981\u91cd\u65b0\u5206\u914d\u66f4\u5927\u7684\u5185\u5b58\u5757\uff0c\u5e76\u590d\u5236\u539f\u6709\u6570\u636e\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6027\u80fd\u95ee\u9898\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u94fe\u8868:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f18\u70b9\uff1a\u6bcf\u4e2a\u8282\u70b9\u72ec\u7acb\u5206\u914d\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u52a8\u6001\u6269\u5c55\uff0c\u4e0d\u4f1a\u9020\u6210\u7a7a\u95f4\u6d6a\u8d39\u3002<\/li>\n\n\n\n<li>\u7f3a\u70b9\uff1a\u6bcf\u4e2a\u8282\u70b9\u9664\u4e86\u5b58\u50a8\u6570\u636e\u5916\u8fd8\u9700\u8981\u989d\u5916\u7684\u7a7a\u95f4\u6765\u5b58\u50a8\u6307\u5411\u4e0b\u4e00\u4e2a\uff08\u4ee5\u53ca\u524d\u4e00\u4e2a\uff0c\u5728\u53cc\u5411\u94fe\u8868\u4e2d\uff09\u8282\u70b9\u7684\u6307\u9488\uff0c\u56e0\u6b64\u76f8\u5bf9\u4e8e\u987a\u5e8f\u8868\u4f1a\u6d88\u8017\u66f4\u591a\u7684\u5185\u5b58\u7a7a\u95f4\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u65f6\u95f4\u590d\u6742\u5ea6<\/h3>\n\n\n\n<p><strong>\u8bbf\u95ee\u5143\u7d20:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u987a\u5e8f\u8868: O(1) - \u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u7d22\u5f15\u5feb\u901f\u8bbf\u95ee\u4efb\u610f\u4f4d\u7f6e\u7684\u5143\u7d20\u3002<\/li>\n\n\n\n<li>\u94fe\u8868: O(n) - \u5fc5\u987b\u4ece\u5934\u8282\u70b9\u5f00\u59cb\u904d\u5386\u5230\u76ee\u6807\u4f4d\u7f6e\uff0c\u5e73\u5747\u60c5\u51b5\u4e0b\u9700\u8981\u8bbf\u95ee\u4e00\u534a\u7684\u8282\u70b9\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u63d2\u5165\/\u5220\u9664\u5143\u7d20:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u987a\u5e8f\u8868:\n<ul class=\"wp-block-list\">\n<li>\u5728\u672b\u5c3e\u63d2\u5165\/\u5220\u9664: O(1)<\/li>\n\n\n\n<li>\u5728\u4e2d\u95f4\u6216\u5f00\u5934\u63d2\u5165\/\u5220\u9664: O(n)\uff0c\u56e0\u4e3a\u53ef\u80fd\u9700\u8981\u79fb\u52a8\u540e\u7eed\u7684\u6240\u6709\u5143\u7d20\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u94fe\u8868:\n<ul class=\"wp-block-list\">\n<li>\u5728\u5df2\u77e5\u4f4d\u7f6e\u63d2\u5165\/\u5220\u9664: O(1)\uff0c\u53ea\u9700\u8981\u4fee\u6539\u524d\u540e\u8282\u70b9\u7684\u6307\u9488\u5373\u53ef\u3002<\/li>\n\n\n\n<li>\u5728\u672a\u77e5\u4f4d\u7f6e\u63d2\u5165\/\u5220\u9664: O(n)\uff0c\u56e0\u4e3a\u9700\u8981\u5148\u904d\u5386\u627e\u5230\u8be5\u4f4d\u7f6e\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u5176\u4ed6\u8003\u8651\u56e0\u7d20<\/h3>\n\n\n\n<p><strong>\u7f13\u5b58\u53cb\u597d\u6027:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u987a\u5e8f\u8868: \u7531\u4e8e\u5143\u7d20\u8fde\u7eed\u5b58\u50a8\uff0c\u8bbf\u95ee\u65f6\u5177\u6709\u8f83\u597d\u7684\u5c40\u90e8\u6027\uff0c\u53ef\u4ee5\u5145\u5206\u5229\u7528CPU\u7f13\u5b58\uff0c\u63d0\u9ad8\u8bfb\u53d6\u901f\u5ea6\u3002<\/li>\n\n\n\n<li>\u94fe\u8868: \u8282\u70b9\u5206\u6563\u5b58\u50a8\uff0c\u8bbf\u95ee\u65f6\u53ef\u80fd\u5bfc\u81f4\u7f13\u5b58\u672a\u547d\u4e2d\uff0c\u964d\u4f4e\u6027\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u52a8\u6001\u8c03\u6574\u5927\u5c0f:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u987a\u5e8f\u8868: \u56fa\u5b9a\u5927\u5c0f\uff0c\u8c03\u6574\u5927\u5c0f\u65f6\u53ef\u80fd\u6d89\u53ca\u5927\u91cf\u6570\u636e\u8fc1\u79fb\u3002<\/li>\n\n\n\n<li>\u94fe\u8868: \u52a8\u6001\u5927\u5c0f\uff0c\u6613\u4e8e\u6269\u5c55\u6216\u6536\u7f29\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u5b9e\u73b0\u96be\u5ea6:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u987a\u5e8f\u8868: \u5b9e\u73b0\u8f83\u4e3a\u7b80\u5355\uff0c\u652f\u6301\u968f\u673a\u8bbf\u95ee\u3002<\/li>\n\n\n\n<li>\u94fe\u8868: \u5b9e\u73b0\u76f8\u5bf9\u590d\u6742\uff0c\u7279\u522b\u662f\u5904\u7406\u8fb9\u754c\u6761\u4ef6\u65f6\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u5e94\u7528\u573a\u666f<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u987a\u5e8f\u8868<\/strong>\u9002\u7528\u4e8e\u9700\u8981\u9891\u7e41\u968f\u673a\u8bbf\u95ee\u4e14\u5143\u7d20\u4e2a\u6570\u53d8\u5316\u4e0d\u5927\u7684\u573a\u5408\u3002<\/li>\n\n\n\n<li><strong>\u94fe\u8868<\/strong>\u5219\u66f4\u9002\u5408\u4e8e\u7ecf\u5e38\u9700\u8981\u63d2\u5165\u5220\u9664\u64cd\u4f5c\u4e14\u5143\u7d20\u4e2a\u6570\u4e0d\u786e\u5b9a\u7684\u60c5\u51b5\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u9009\u62e9\u54ea\u79cd\u6570\u636e\u7ed3\u6784\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u5e94\u7528\u9700\u6c42\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u5927\u91cf\u7684\u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c\uff0c\u540c\u65f6\u5bf9\u5185\u5b58\u5229\u7528\u7387\u6709\u8f83\u9ad8\u8981\u6c42\uff0c\u90a3\u4e48\u94fe\u8868\u53ef\u80fd\u662f\u66f4\u597d\u7684\u9009\u62e9\u3002\u76f8\u53cd\uff0c\u5982\u679c\u5e94\u7528\u4e3b\u8981\u5173\u6ce8\u5feb\u901f\u67e5\u627e\u7279\u5b9a\u5143\u7d20\u6216\u8005\u6267\u884c\u6279\u91cf\u64cd\u4f5c\uff0c\u90a3\u4e48\u987a\u5e8f\u8868\u5c06\u662f\u66f4\u4f18\u7684\u9009\u62e9\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5177\u4f53\u5b9e\u4f8b<\/h2>\n\n\n\n<p>\u8fd9\u6b21\u7684\u5177\u4f53\u4f8b\u5b50\u6ca1\u50cf\u4e0a\u4e00\u7bc7\u987a\u5e8f\u8868\u7ed9\u4e86\u4e24\u4e2a\u4f8b\u5b50\uff0c\u8fd9\u6b21\u53ea\u5199\u4e86\u4e00\u4e2a\u4f8b\u5b50\uff0c\u8fd9\u4e2a\u4f8b\u5b50\u5305\u542b\u4e0a\u9762\u5355\u94fe\u8868\u7684\u6240\u6709\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5355\u94fe\u8868<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\ntypedef int ElemType;\ntypedef int Status;\n#define OK 1\n#define ERROR 0\n#define OVERFLOW -1\n#define MAXSIZE 100\n\n\ntypedef struct LNode {\n\tElemType elem;\/\/\u7ed3\u70b9\u7684\u6570\u636e\u57df\n\tstruct LNode* next;\n}LNode,*LinkList;\n\n\n\/\/\u521d\u59cb\u5316\nint InitList(LinkList&amp; L) {\n\tL = new LNode;\n\tL-&gt;next = NULL;\n\treturn OK;\n}\n\n\n\/\/\u53d6\u503c\nint GetElem(LinkList L, int i, ElemType&amp; e) {\n\tLNode* p;\n\tp = L-&gt;next;\/\/\u521d\u59cb\u5316\u3002p\u6307\u5411\u9996\u5143\u7ed3\u70b9\n\t\tint j = 1;\n\t\twhile (p &amp;&amp; j &lt; i) {\n\t\t\tp = p-&gt;next;\n\t\t\tj++;\n\t\t}\n\t\tif (!p || j &gt; i) {\n\t\t\t\/\/i\u503c\u4e0d\u5408\u6cd5\n\t\t\treturn ERROR;\n\t\t}\n\t\te = p-&gt;elem;\n\t\treturn OK;\n}\n\n\/\/\u67e5\u627e \u5143\u7d20\u67e5\u627e\nLNode* LocateElem(LinkList L, ElemType e) {\n\tLNode* p;\n\tp = L-&gt;next;\n\twhile (p &amp;&amp; p-&gt;elem != e) {\n\t\tp = p-&gt;next;\n\t}\n\treturn p;\n}\n\n\/\/\u67e5\u627e  \u4f4d\u7f6e\u67e5\u627e\nLNode* LocateElem1(LinkList L, int i) {\n\tLNode* p = L;\n\tint count = 1;\n\twhile (p != NULL &amp;&amp; count &lt; i) {\n\t\tp = p-&gt;next;\n\t\tcount++;\n\t}\n\tif (p != NULL) {\n\t\treturn p;\n\t}\n\telse {\n\t\treturn NULL;\n\t}\n}\n\n\/\/\u524d\u63d2\u6cd5\u521b\u5efa\u5355\u94fe\u8868\nvoid CreateList_H(LinkList&amp; L, int n) {\n\tL = new LNode;\n\tL-&gt;next = NULL;\n\tLNode* p;\n\tfor (int i = 0; i &lt; n; i++) {\n\t\tp = new LNode;\n\t\tcin &gt;&gt; p-&gt;elem;\n\t\tp-&gt;next = L-&gt;next;\n\t\tL-&gt;next = p;\n\t}\n}\n\/\/\u540e\u63d2\u6cd5\u521b\u5efa\u5355\u94fe\u8868\nvoid CreateList_B(LinkList&amp; L, int n) {\n\t\/\/\u6b63\u4f4d\u5e8f\u8f93\u5165n\u4e2a\u5143\u7d20\u7684\u503c\uff0c\u5efa\u7acb\u5e26\u8868\u5934\u8282\u70b9\u7684\u5355\u94fe\u8868L\n\tL = new LNode;\n\tL-&gt;next = NULL;\n\tLinkList r;\n\tr = L;\n\tLinkList p;\n\tfor (int i = 0; i &lt; n; i++) {\n\t\tp = new LNode;\n\t\tcin &gt;&gt; p-&gt;elem;\n\t\tp-&gt;next = NULL;\n\t\tr-&gt;next = p;\n\t\tr = p;\n\t}\n}\n\n\/\/\u6253\u5370\u94fe\u8868\nvoid PrintList(LinkList L) {\n\tLinkList temp = L-&gt;next;\/\/\u4ece\u5934\u7ed3\u70b9\u7684next\u5f00\u59cb\u6253\u5370\n\twhile (temp != NULL) {\n\t\tprintf(\"%d \", temp-&gt;elem);\n\t\ttemp = temp-&gt;next;\n\t}\n\tprintf(\"\\n\");\n}\n\n\/\/\u63d2\u5165\nint ListInsert(LinkList&amp; L, int i, ElemType e) {\n\t\/\/\u5728\u5e26\u5934\u7ed3\u70b9\u7684\u5355\u94fe\u8868L\u4e2d\u7b2ci\u4e2a\u4f4d\u7f6e\u63d2\u5165\u503c\u4e3ae\u7684\u65b0\u7ed3\u70b9\n\tLNode* p;\n\tp = L;\n\tint j = 0;\n\twhile (p &amp;&amp; (j &lt; i - 1)) {\/\/\u67e5\u627e\u7b2ci-1\u4e2a\u7ed3\u70b9\uff0cp\u6307\u5411\u8be5\u7ed3\u70b9\n\t\tp = p-&gt;next;\n\t\tj++;\n\t}\n\tif (!p || j &gt; i - 1) {\/\/i&gt;n+1\u6216\u8005i&lt;1\n\t\treturn ERROR;\n\t}\n\tLNode* s;\n\ts = new LNode;\/\/\u751f\u6210\u65b0\u7ed3\u70b9*s\n\ts-&gt;elem = e;\/\/\u5c06\u7ed3\u70b9*s\u7684\u6570\u636e\u57df\u7f6e\u4e3ae\n\ts-&gt;next = p-&gt;next;\/\/\u5c06\u7ed3\u70b9*s\u7684\u6307\u9488\u57df\u6307\u5411\u7ed3\u70b9\n\tp-&gt;next = s;\/\/\u5c06\u7ed3\u70b9*p\u7684\u6307\u9488\u57df\u6307\u5411\u7ed3\u70b9*s\n\treturn OK;\n}\n\n\/\/\u5408\u5e76\nvoid MergeList_L(LinkList&amp; LA, LinkList&amp; LB, LinkList&amp; LC) {\n\t\/\/\u5df2\u77e5\u5355\u94fe\u8868LA\u548cLB\u7684\u5143\u7d20\u6309\u503c\u975e\u9012\u51cf\u6392\u5217\n\t\/\/\u5f52\u5e76LA\u548cLB\u5f97\u5230\u65b0\u7684\u5355\u94fe\u8868LC,LC\u7684\u5143\u7d20\u4e5f\u6309\u503c\u975e\u9012\u51cf\u6392\u5217\n\tLNode* pa;\n\tLNode* pb;\n\tLNode* pc;\n\tpa = LA-&gt;next;  \n\tpb = LB-&gt;next;  \n\tLC = LA;        \/\/\u7528LA\u7684\u5934\u7ed3\u70b9\u4f5c\u4e3aLC\u7684\u5934\u7ed3\u70b9\n\tpc = LC;        \/\/pc\u7684\u521d\u503c\u6307\u5411LC\u7684\u5934\u7ed3\u70b9\n\twhile (pa &amp;&amp; pb) {\n\t\t\/\/LA\u548cLB\u5747\u672a\u5230\u8fbe\u8868\u5c3e\uff0c\u4f9d\u6b21\u201c\u6458\u53d6\u201d\u4e24\u8868\u4e2d\u503c\u8f83\u5c0f\u7684\u7ed3\u70b9\u63d2\u5165\u5230LC\u7684\u6700\u540e\n\t\tif (pa-&gt;elem &lt;= pb-&gt;elem) {  \/\/\u6458\u53d6pa\u7684\u7ed3\u70b9\n\t\t\tpc-&gt;next = pa;   \/\/\u5c06pa\u6240\u6307\u7ed3\u70b9\u94fe\u63a5\u5230pc\u6240\u6307\u7ed3\u70b9\u4e4b\u540e\n\t\t\tpc = pa;         \/\/pc\u6307\u5411pa\n\t\t\tpa = pa-&gt;next;   \/\/pa\u6307\u5411\u4e0b\u4e00\u4e2a\u7ed3\u70b9\n\t\t}\n\t\telse {\/\/\u6458\u53d6pb\u7684\u7ed3\u70b9\n\t\t\tpc-&gt;next = pb;   \/\/\u5c06pb\u6240\u6307\u7ed3\u70b9\u94fe\u63a5\u5230pc\u6240\u6307\u7ed3\u70b9\u4e4b\u540e\n\t\t\tpc = pb;         \/\/pc\u6307\u5411pb\n\t\t\tpb = pb-&gt;next;   \/\/pb\u6307\u5411\u4e0b\u4e00\u8282\u70b9\n\t\t}\n\t}\n\tpc-&gt;next = pa ? pa : pb; \/\/\u5c06\u975e\u7a7a\u8868\u7684\u5269\u4f59\u6bb5\u63d2\u5165\u5230pc\u6240\u6307\u7ed3\u70b9\u4e4b\u540e\n\tdelete LB;               \/\/\u91ca\u653eLB\u7684\u5934\u7ed3\u70b9\n}\nint main() {\n\tLinkList L1 = NULL, L2 = NULL, L3 = NULL;\n\tint choice, position, value, n;\n\tStatus status;\n\tElemType e;\n\tbool isInitList = false;\n\n\tdo {\n\t\tcout &lt;&lt; \"\u8bf7\u9009\u62e9\u64cd\u4f5c\uff1a\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"1. \u521d\u59cb\u5316\u94fe\u8868\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"2. \u63d2\u5165\u5143\u7d20\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"3. \u6253\u5370\u94fe\u8868\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"4. \u521b\u5efa\u94fe\u8868(\u524d\u63d2\u6cd5)\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"5. \u521b\u5efa\u94fe\u8868(\u540e\u63d2\u6cd5)\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"6. \u67e5\u627e\u5143\u7d20\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"7. \u4f4d\u7f6e\u67e5\u627e\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"8. \u5408\u5e76\u94fe\u8868\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"0. \u9000\u51fa\" &lt;&lt; endl;\n\t\tcin &gt;&gt; choice;\n\n\t\tif (!isInitList &amp;&amp; (choice &gt;= 2 &amp;&amp; choice &lt;= 8)) {\n\t\t\tcout &lt;&lt; \"\u8bf7\u5148\u521d\u59cb\u5316\u94fe\u8868!\" &lt;&lt; endl;\n\t\t\tcontinue;\n\t\t}\n\n\t\tswitch (choice) {\n\t\tcase 1:\n\t\t\tstatus = InitList(L1);\n\t\t\tif (status == OK) {\n\t\t\t\tcout &lt;&lt; \"\u521d\u59cb\u5316\u94fe\u8868\u6210\u529f!\" &lt;&lt; endl;\n\t\t\t\tisInitList = true;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u63d2\u5165\u7684\u4f4d\u7f6e\u548c\u5143\u7d20: \";\n\t\t\tcin &gt;&gt; position &gt;&gt; value;\n\t\t\tstatus = ListInsert(L1, position, value);\n\t\t\tif (status == OK) {\n\t\t\t\tcout &lt;&lt; \"\u63d2\u5165\u6210\u529f!\" &lt;&lt; endl;\n\t\t\t}\n\t\t\telse cout &lt;&lt; \"\u63d2\u5165\u5931\u8d25\" &lt;&lt; endl;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tPrintList(L1);\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u94fe\u8868\u957f\u5ea6: \";\n\t\t\tcin &gt;&gt; n;\n\t\t\tCreateList_H(L1, n);\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u94fe\u8868\u957f\u5ea6: \";\n\t\t\tcin &gt;&gt; n;\n\t\t\tCreateList_B(L1, n);\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u67e5\u627e\u7684\u5143\u7d20: \";\n\t\t\tcin &gt;&gt; e;\n\t\t\tif (LocateElem(L1, e) != NULL) {\n\t\t\t\tcout &lt;&lt; \"\u627e\u5230\u5143\u7d20: \" &lt;&lt; e &lt;&lt; endl;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcout &lt;&lt; \"\u672a\u627e\u5230\u5143\u7d20: \" &lt;&lt; e &lt;&lt; endl;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u67e5\u627e\u7684\u4f4d\u7f6e: \";\n\t\t\tcin &gt;&gt; position;\n\t\t\tif (LocateElem1(L1, position) != NULL) {\n\t\t\t\tcout &lt;&lt; \"\u627e\u5230\u4f4d\u7f6e: \" &lt;&lt; position &lt;&lt; endl;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcout &lt;&lt; \"\u672a\u627e\u5230\u4f4d\u7f6e: \" &lt;&lt; position &lt;&lt; endl;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tInitList(L2);\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u94fe\u8868\u7684\u957f\u5ea6: \";\n\t\t\tcin &gt;&gt; n;\n\t\t\tCreateList_B(L2, n);\n\t\t\tMergeList_L(L1, L2, L3);\n\t\t\tL1 = L3; \/\/ \u66f4\u65b0L1\u4e3a\u5408\u5e76\u540e\u7684\u94fe\u8868\n\t\t\tbreak;\n\t\tcase 0:\n\t\t\tcout &lt;&lt; \"\u7a0b\u5e8f\u7ed3\u675f\" &lt;&lt; endl;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tcout &lt;&lt; \"\u65e0\u6548\u7684\u9009\u62e9\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\" &lt;&lt; endl;\n\t\t}\n\t} while (choice != 0);\n\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<p>\u540c\u6837\uff0c\u8fd9\u4e2a\u4f8b\u5b50\u4e5f\u4e0d\u518d\u8fc7\u591a\u89e3\u91ca\uff0c\u6709\u770b\u4e0d\u61c2\u7684\u5730\u65b9\u5c31\u53bb\u770b\u4e0a\u6587\u5355\u94fe\u8868\u6bcf\u4e2a\u64cd\u4f5c\u7684\u89e3\u91ca\uff0c\u540c\u65f6\uff0c\u8fd9\u4e2a\u4f8b\u5b50\u4e5f\u53ea\u662f\u5c06\u8fd9\u4e9b\u64cd\u4f5c\u6c47\u603b\u4e86\uff0c\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u4e5f\u662f\u6ca1\u90a3\u4e48\u5f3a\uff0c\u53ea\u662f\u4e00\u4e2a\u53c2\u8003\u4f5c\u7528\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u53cc\u5411\u94fe\u8868<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream&gt;\nusing namespace std;\ntypedef int ElemType;\n#define ERROR 0\n#define OK 1\ntypedef struct DNode {\n\tElemType elem;  \/\/\u7ed3\u70b9\u7684\u6570\u636e\u57df\n\tstruct DNode* prev; \/\/\u6307\u5411\u524d\u9a71\u7ed3\u70b9\n\tstruct DNode* next; \/\/\u6307\u5411\u540e\u7ee7\u8282\u70b9\n}DNode,*DLinkList;\n\nint InitDList(DLinkList&amp; L) {\n\tL = new DNode;\n\tif (L == NULL) {\n\t\tcout &lt;&lt; \"\u5185\u5b58\u5206\u914d\u5931\u8d25\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\tL-&gt;next = L-&gt;prev = L; \/\/\u5934\u7ed3\u70b9\u7684\u524d\u9a71\u548c\u540e\u7ee7\u90fd\u6307\u5411\u81ea\u5df1\n\treturn OK;\n}\n\n\/\/\u63d2\u5165\nint InsertDList(DLinkList&amp; L, int i, ElemType e) {\n\tif (i &lt;= 0) {\n\t\tcout &lt;&lt; \"\u4f4d\u7f6e\u5fc5\u987b\u5927\u4e8e0\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\tDNode* p = L;\n\tint j = 0;\n\twhile (p &amp;&amp; (j &lt; i - 1)) {\n\t\tp = p-&gt;next;\n\t\tj++;\n\t}\n\tif (!p || j &gt; i - 1) {\n\t\tcout &lt;&lt; \"\u8d85\u51fa\u94fe\u8868\u8303\u56f4\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\tDNode* s = new DNode;\n\tif (s == NULL) {\n\t\tcout &lt;&lt; \"\u5185\u5b58\u5206\u914d\u5931\u8d25\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\ts-&gt;elem = e;\n\ts-&gt;next = p-&gt;next;\n\tif (p-&gt;next) {\n\t\tp-&gt;next-&gt;prev = s;\n\t}\n\ts-&gt;prev = p;\n\tp-&gt;next = s;\n\treturn OK;\n}\n\n\/\/\u5220\u9664\u5143\u7d20\nint DeleteDList(DLinkList&amp; L, int i, ElemType&amp; e) {\n\tif (i &lt; 0) {\n\t\tcout &lt;&lt; \"\u4f4d\u7f6e\u5fc5\u987b\u5927\u4e8e0\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\tDNode* p = L;\n\tint j = 0;\n\twhile (p &amp;&amp; (j &lt; i)) {\n\t\tp = p-&gt;next;\n\t\tj++;\n\t}\n\tif (!p || j &gt; i) {\n\t\tcout &lt;&lt; \"\u4f4d\u7f6e\u8d85\u51fa\u8303\u56f4\" &lt;&lt; endl;\n\t\treturn ERROR;\n\t}\n\te = p-&gt;elem;\n\tp-&gt;prev-&gt;next = p-&gt;next;\n\tif (p-&gt;next) {\n\t\tp-&gt;next-&gt;prev = p-&gt;prev;\n\t}\n\tdelete p;\n\treturn OK;\n}\n\n\/\/\u67e5\u627e\nDNode* LocateElem(DLinkList L, ElemType e) {\n\tDNode* p=L-&gt;next;\n\twhile (p != L &amp;&amp; p-&gt;elem != e) {\n\t\tp = p-&gt;next;\n\t}\n\treturn (p == L) ? NULL : p;\n}\n\n\/\/\u6253\u5370\u94fe\u8868\nvoid PrintDList(DLinkList L) {\n\tDNode* temp = L-&gt;next;\n\twhile (temp != L) {\n\t\tcout &lt;&lt; temp-&gt;elem &lt;&lt; \" \";\n\t\ttemp = temp-&gt;next;\n\t}\n\tcout &lt;&lt; endl;\n}\n\n\/\/\u83b7\u53d6\u957f\u5ea6\nint LengthDList(DLinkList L) {\n\tint length = 0;\n\tDNode* p = L-&gt;next;\n\twhile (p != L) {\n\t\tlength++;\n\t\tp = p-&gt;next;\n\t}\n\treturn length;\n}\n\n\/\/\u6e05\u7a7a\nvoid ClearDList(DLinkList&amp; L) {\n\tDNode* p = L-&gt;next;\n\twhile (p != L) {\n\t\tDNode* next = p-&gt;next;\n\t\tdelete p;\n\t\tp = next;\n\t}\n\tL-&gt;next = L-&gt;prev = L;  \/\/ \u91cd\u65b0\u521d\u59cb\u5316\u5934\u7ed3\u70b9\n}\n\n\/\/\u5c3e\u90e8\u63d2\u5165\nint AppendDList(DLinkList&amp; L, ElemType e) {\n\tDNode* s = new DNode;\n\tif (s == NULL) {\n\t\tcout &lt;&lt; \"\u5185\u5b58\u5206\u914d\u5931\u8d25\uff01\" &lt;&lt; endl;\n\t\treturn -1;\n\t}\n\ts-&gt;elem = e;\n\n\t\/\/ \u627e\u5230\u94fe\u8868\u7684\u6700\u540e\u4e00\u4e2a\u8282\u70b9\n\tDNode* last = L-&gt;prev;\n\tlast-&gt;next = s;\n\ts-&gt;prev = last;\n\ts-&gt;next = L;\n\tL-&gt;prev = s;\n\n\treturn 0;\n}\n\n\/\/\u5934\u90e8\u63d2\u5165\nint PrependDList(DLinkList&amp; L, ElemType e) {\n\tDNode* s = new DNode;\n\tif (s == NULL) {\n\t\tcout &lt;&lt; \"\u5185\u5b58\u5206\u914d\u5931\u8d25\uff01\" &lt;&lt; endl;\n\t\treturn -1;\n\t}\n\ts-&gt;elem = e;\n\n\t\/\/ \u5934\u7ed3\u70b9\u7684\u4e0b\u4e00\u4e2a\u8282\u70b9\n\tDNode* first = L-&gt;next;\n\tL-&gt;next = s;\n\ts-&gt;prev = L;\n\ts-&gt;next = first;\n\tfirst-&gt;prev = s;\n\n\treturn 0;\n}\n\n\/\/\u6309\u503c\u5220\u9664\nint DeleteByValue(DLinkList&amp; L, ElemType e) {\n\tDNode* p = L-&gt;next;\n\twhile (p != L &amp;&amp; p-&gt;elem != e) {\n\t\tp = p-&gt;next;\n\t}\n\tif (p == L) {\n\t\tcout &lt;&lt; \"\u672a\u627e\u5230\u8981\u5220\u9664\u7684\u5143\u7d20: \" &lt;&lt; e &lt;&lt; endl;\n\t\treturn -1;\n\t}\n\n\tp-&gt;prev-&gt;next = p-&gt;next;\n\tif (p-&gt;next) {\n\t\tp-&gt;next-&gt;prev = p-&gt;prev;\n\t}\n\tdelete p;\n\n\treturn 0;\n}\n\n\/\/\u53cd\u8f6c\u94fe\u8868\nvoid ReverseDList(DLinkList&amp; L) {\n\tDNode* p = L-&gt;next;\n\tDNode* q = NULL;\n\twhile (p != L) {\n\t\tq = p-&gt;next;\n\t\tp-&gt;next = p-&gt;prev;\n\t\tp-&gt;prev = q;\n\t\tif (q == L) {\n\t\t\tL-&gt;next = p;\n\t\t\tp-&gt;prev = L;\n\t\t}\n\t\tp = q;\n\t}\n}\n\n\/\/\u524d\u63d2\u6cd5\u521b\u5efa\u53cc\u5411\u94fe\u8868\nvoid CreateList_H(DLinkList&amp; L, int n) {\n\tDNode* s;\n\tfor (int i = 0; i &lt; n; i++) {\n\t\ts = new DNode;\n\t\tif (s == NULL) {\n\t\t\tcout &lt;&lt; \"\u5185\u5b58\u5206\u914d\u5931\u8d25\" &lt;&lt; endl;\n\t\t}\n\t\tcin &gt;&gt; s-&gt;elem;\n\t\ts-&gt;next = L-&gt;next;  \/\/\u65b0\u7ed3\u70b9\u7684next\u6307\u5411\u539f\u5934\u7ed3\u70b9\u7684next\n\t\ts-&gt;prev = L;        \/\/\u65b0\u7ed3\u70b9\u7684prev\u6307\u5411\u5934\u7ed3\u70b9\n\n\t\tL-&gt;next-&gt;prev = s;  \/\/\u539f\u5934\u7ed3\u70b9\u7684next\u7684prev\u6307\u5411\u65b0\u7ed3\u70b9\n\t\tL-&gt;next = s;\n\t}\n}\n\n\/\/\u540e\u63d2\u6cd5\u521b\u5efa\u53cc\u5411\u94fe\u8868\nvoid CreateList_B(DLinkList&amp; L, int n) {\n\tDNode* s;\n\tfor (int i = 0; i &lt; n; i++) {\n\t\ts = new DNode;\n\t\tif (s == NULL) {\n\t\t\tcout &lt;&lt; \"\u5185\u5b58\u5206\u914d\u5931\u8d25\" &lt;&lt; endl;\n\t\t}\n\t\tcin &gt;&gt; s-&gt;elem;\n\t\ts-&gt;next = L;  \/\/\u65b0\u7ed3\u70b9\u7684next\u6307\u5411\u5934\u7ed3\u70b9\n\t\ts-&gt;prev = L-&gt;prev; \/\/\u65b0\u7ed3\u70b9\u7684prev\u6307\u5411\u539f\u5c3e\u7ed3\u70b9\n\n\t\tL-&gt;prev-&gt;next = s; \/\/\u539f\u5c3e\u7ed3\u70b9\u7684next\u6307\u5411\u65b0\u7ed3\u70b9\n\t\tL-&gt;prev = s;       \/\/\u5934\u7ed3\u70b9\u7684prev\u6307\u5411\u65b0\u7ed3\u70b9\n\t}\n}\n\nint main() {\n\tDLinkList L;\n\tint choice, position, value, result,p;\n\tElemType element;\n\tDNode* foundNode = NULL;  \/\/ \u5728\u8fd9\u91cc\u58f0\u660e\u548c\u521d\u59cb\u5316 foundNode\n\n\t\/\/ \u521d\u59cb\u5316\u53cc\u5411\u94fe\u8868\n\tif (InitDList(L) != OK) {\n\t\tcout &lt;&lt; \"\u521d\u59cb\u5316\u5931\u8d25\" &lt;&lt; endl;\n\t\treturn -1;\n\t}\n\n\twhile (true) {\n\t\tcout &lt;&lt; \"\\n\u53cc\u5411\u94fe\u8868\u64cd\u4f5c\u83dc\u5355\uff1a\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"1. \u63d2\u5165\u5143\u7d20\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"2. \u5220\u9664\u5143\u7d20\uff08\u6309\u4f4d\u7f6e\uff09\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"3. \u67e5\u627e\u5143\u7d20\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"4. \u6253\u5370\u94fe\u8868\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"5. \u83b7\u53d6\u94fe\u8868\u957f\u5ea6\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"6. \u6e05\u7a7a\u94fe\u8868\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"7. \u5c3e\u90e8\u63d2\u5165\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"8. \u5934\u90e8\u63d2\u5165\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"9. \u6309\u503c\u5220\u9664\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"10. \u53cd\u8f6c\u94fe\u8868\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"11. \u5934\u63d2\u6cd5\u521b\u5efa\u53cc\u5411\u94fe\u8868\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"12. \u5c3e\u63d2\u6cd5\u521b\u5efa\u53cc\u5411\u94fe\u8868\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"0. \u9000\u51fa\" &lt;&lt; endl;\n\t\tcout &lt;&lt; \"\u8bf7\u9009\u62e9\u64cd\u4f5c\uff1a\";\n\t\tcin &gt;&gt; choice;\n\n\t\tswitch (choice) {\n\t\tcase 1:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u63d2\u5165\u7684\u4f4d\u7f6e\u548c\u5143\u7d20\uff1a\";\n\t\t\tcin &gt;&gt; position &gt;&gt; element;\n\t\t\tresult = InsertDList(L, position, element);\n\t\t\tif (result == OK) {\n\t\t\t\tcout &lt;&lt; \"\u63d2\u5165\u6210\u529f\" &lt;&lt; endl;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcout &lt;&lt; \"\u63d2\u5165\u5931\u8d25\" &lt;&lt; endl;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u5220\u9664\u7684\u4f4d\u7f6e\uff1a\";\n\t\t\tcin &gt;&gt; position;\n\t\t\tresult = DeleteDList(L, position, element);\n\t\t\tif (result == OK) {\n\t\t\t\tcout &lt;&lt; \"\u5220\u9664\u6210\u529f\uff0c\u88ab\u5220\u9664\u7684\u5143\u7d20\u662f: \" &lt;&lt; element &lt;&lt; endl;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcout &lt;&lt; \"\u5220\u9664\u5931\u8d25\" &lt;&lt; endl;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u67e5\u627e\u7684\u5143\u7d20\uff1a\";\n\t\t\tcin &gt;&gt; element;\n\t\t\tfoundNode = LocateElem(L, element);  \/\/ \u5728\u8fd9\u91cc\u4f7f\u7528 foundNode\n\t\t\tif (foundNode) {\n\t\t\t\tcout &lt;&lt; \"\u627e\u5230\u5143\u7d20: \" &lt;&lt; foundNode-&gt;elem &lt;&lt; endl;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcout &lt;&lt; \"\u672a\u627e\u5230\u5143\u7d20\" &lt;&lt; endl;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tcout &lt;&lt; \"\u94fe\u8868\u5185\u5bb9\uff1a\";\n\t\t\tPrintDList(L);\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tcout &lt;&lt; \"\u94fe\u8868\u957f\u5ea6: \" &lt;&lt; LengthDList(L) &lt;&lt; endl;\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tClearDList(L);\n\t\t\tcout &lt;&lt; \"\u94fe\u8868\u5df2\u6e05\u7a7a\" &lt;&lt; endl;\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u5c3e\u90e8\u63d2\u5165\u7684\u5143\u7d20\uff1a\";\n\t\t\tcin &gt;&gt; element;\n\t\t\tresult = AppendDList(L, element);\n\t\t\tif (result == 0) {\n\t\t\t\tcout &lt;&lt; \"\u5c3e\u90e8\u63d2\u5165\u6210\u529f\" &lt;&lt; endl;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcout &lt;&lt; \"\u5c3e\u90e8\u63d2\u5165\u5931\u8d25\" &lt;&lt; endl;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u5934\u90e8\u63d2\u5165\u7684\u5143\u7d20\uff1a\";\n\t\t\tcin &gt;&gt; element;\n\t\t\tresult = PrependDList(L, element);\n\t\t\tif (result == 0) {\n\t\t\t\tcout &lt;&lt; \"\u5934\u90e8\u63d2\u5165\u6210\u529f\" &lt;&lt; endl;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcout &lt;&lt; \"\u5934\u90e8\u63d2\u5165\u5931\u8d25\" &lt;&lt; endl;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 9:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u5220\u9664\u7684\u5143\u7d20\uff1a\";\n\t\t\tcin &gt;&gt; element;\n\t\t\tresult = DeleteByValue(L, element);\n\t\t\tif (result == 0) {\n\t\t\t\tcout &lt;&lt; \"\u6309\u503c\u5220\u9664\u6210\u529f\" &lt;&lt; endl;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcout &lt;&lt; \"\u6309\u503c\u5220\u9664\u5931\u8d25\" &lt;&lt; endl;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 10:\n\t\t\tReverseDList(L);\n\t\t\tcout &lt;&lt; \"\u94fe\u8868\u5df2\u53cd\u8f6c\" &lt;&lt; endl;\n\t\t\tbreak;\n\t\tcase 11:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u94fe\u8868\u7684\u957f\u5ea6\" &lt;&lt; endl;\n\t\t\tcin &gt;&gt; p;\n\t\t\tCreateList_H(L, p);\n\t\t\tbreak;\n\t\tcase 12:\n\t\t\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u94fe\u8868\u7684\u957f\u5ea6\" &lt;&lt; endl;\n\t\t\tcin &gt;&gt; p;\n\t\t\tCreateList_B(L,p);\n\t\t\tbreak;\n\t\tcase 0:\n\t\t\tcout &lt;&lt; \"\u9000\u51fa\u7a0b\u5e8f\" &lt;&lt; endl;\n\t\t\treturn 0;\n\t\tdefault:\n\t\t\tcout &lt;&lt; \"\u65e0\u6548\u7684\u9009\u62e9\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\" &lt;&lt; endl;\n\t\t}\n\t}\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u662f\u53cc\u5411\u94fe\u8868\u7684\u57fa\u672c\u64cd\u4f5c\u6c47\u603b\uff0c\u91cc\u9762\u7684\u64cd\u4f5c\u5927\u591a\u548c\u5355\u94fe\u8868\u76f8\u4f3c\uff0c\u7ed3\u5408\u7740\u53cc\u7ebf\u94fe\u8868\u7684\u56fe\u8fd8\u662f\u5f88\u597d\u7406\u89e3\u7684\uff0c\u8fd9\u91cc\u8bb2\u4e00\u4e0b\u6211\u8ba4\u4e3a\u4e0d\u592a\u597d\u7406\u89e3\u7684\u53cc\u5411\u94fe\u8868\u7684\u53cd\u8f6c\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<p>\u53cd\u8f6c\u53cc\u5411\u94fe\u8868\u7684\u64cd\u4f5c\u662f\u5c06\u94fe\u8868\u4e2d\u7684\u8282\u70b9\u987a\u5e8f\u5b8c\u5168\u98a0\u5012\u8fc7\u6765\u3002\u5728\u53cc\u5411\u94fe\u8868\u4e2d\uff0c\u6bcf\u4e2a\u8282\u70b9\u90fd\u6709\u4e00\u4e2a <code>prev<\/code> \u6307\u9488\u6307\u5411\u524d\u9a71\u8282\u70b9\u548c\u4e00\u4e2a <code>next<\/code> \u6307\u9488\u6307\u5411\u540e\u7ee7\u8282\u70b9\u3002\u53cd\u8f6c\u94fe\u8868\u65f6\uff0c\u6211\u4eec\u9700\u8981\u4ea4\u6362\u8fd9\u4e9b\u6307\u9488\u7684\u65b9\u5411\uff0c\u4f7f\u5f97\u539f\u6765\u7684 <code>next<\/code> \u6307\u9488\u53d8\u6210 <code>prev<\/code>\uff0c\u539f\u6765\u7684 <code>prev<\/code> \u6307\u9488\u53d8\u6210 <code>next<\/code>\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u7ed9\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n\n\n\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u53cc\u5411\u94fe\u8868 <code>L<\/code>\uff0c\u5176\u5185\u5bb9\u4e3a <code>1 &lt;-&gt; 2 &lt;-&gt; 3 &lt;-&gt; 4<\/code>\uff0c\u73b0\u5728\u6211\u4eec\u8981\u53cd\u8f6c\u8fd9\u4e2a\u94fe\u8868\u3002\u4ee5\u4e0b\u662f\u5177\u4f53\u7684\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u521d\u59cb\u5316<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u53cc\u5411\u94fe\u8868&nbsp;<code>L<\/code>\uff1a<code>1 &lt;-&gt; 2 &lt;-&gt; 3 &lt;-&gt; 4<\/code><\/li>\n\n\n\n<li><code>p<\/code>&nbsp;\u4ece\u7b2c\u4e00\u4e2a\u5b9e\u9645\u8282\u70b9&nbsp;<code>1<\/code>&nbsp;\u5f00\u59cb\uff0c<code>q<\/code>&nbsp;\u521d\u59cb\u5316\u4e3a&nbsp;<code>NULL<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u7b2c\u4e00\u6b21\u8fed\u4ee3<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><code>p<\/code>&nbsp;\u6307\u5411&nbsp;<code>1<\/code>\uff0c<code>q<\/code>&nbsp;\u4fdd\u5b58&nbsp;<code>p-&gt;next<\/code>&nbsp;\u5373&nbsp;<code>2<\/code>\u3002<\/li>\n\n\n\n<li>\u4ea4\u6362&nbsp;<code>p<\/code>&nbsp;\u7684&nbsp;<code>prev<\/code>&nbsp;\u548c&nbsp;<code>next<\/code>\uff0c<code>p-&gt;next<\/code>&nbsp;\u6307\u5411&nbsp;<code>L<\/code>\uff08\u5934\u7ed3\u70b9\uff09\uff0c<code>p-&gt;prev<\/code>&nbsp;\u6307\u5411&nbsp;<code>2<\/code>\u3002<\/li>\n\n\n\n<li>\u79fb\u52a8&nbsp;<code>p<\/code>&nbsp;\u5230&nbsp;<code>2<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u7b2c\u4e8c\u6b21\u8fed\u4ee3<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><code>p<\/code>&nbsp;\u6307\u5411&nbsp;<code>2<\/code>\uff0c<code>q<\/code>&nbsp;\u4fdd\u5b58&nbsp;<code>p-&gt;next<\/code>&nbsp;\u5373&nbsp;<code>3<\/code>\u3002<\/li>\n\n\n\n<li>\u4ea4\u6362&nbsp;<code>p<\/code>&nbsp;\u7684&nbsp;<code>prev<\/code>&nbsp;\u548c&nbsp;<code>next<\/code>\uff0c<code>p-&gt;next<\/code>&nbsp;\u6307\u5411&nbsp;<code>1<\/code>\uff0c<code>p-&gt;prev<\/code>&nbsp;\u6307\u5411&nbsp;<code>3<\/code>\u3002<\/li>\n\n\n\n<li>\u79fb\u52a8&nbsp;<code>p<\/code>&nbsp;\u5230&nbsp;<code>3<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u7b2c\u4e09\u6b21\u8fed\u4ee3<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><code>p<\/code>&nbsp;\u6307\u5411&nbsp;<code>3<\/code>\uff0c<code>q<\/code>&nbsp;\u4fdd\u5b58&nbsp;<code>p-&gt;next<\/code>&nbsp;\u5373&nbsp;<code>4<\/code>\u3002<\/li>\n\n\n\n<li>\u4ea4\u6362&nbsp;<code>p<\/code>&nbsp;\u7684&nbsp;<code>prev<\/code>&nbsp;\u548c&nbsp;<code>next<\/code>\uff0c<code>p-&gt;next<\/code>&nbsp;\u6307\u5411&nbsp;<code>2<\/code>\uff0c<code>p-&gt;prev<\/code>&nbsp;\u6307\u5411&nbsp;<code>4<\/code>\u3002<\/li>\n\n\n\n<li>\u79fb\u52a8&nbsp;<code>p<\/code>&nbsp;\u5230&nbsp;<code>4<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u7b2c\u56db\u6b21\u8fed\u4ee3<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><code>p<\/code>&nbsp;\u6307\u5411&nbsp;<code>4<\/code>\uff0c<code>q<\/code>&nbsp;\u4fdd\u5b58&nbsp;<code>p-&gt;next<\/code>&nbsp;\u5373&nbsp;<code>L<\/code>\uff08\u5934\u7ed3\u70b9\uff09\u3002<\/li>\n\n\n\n<li>\u4ea4\u6362&nbsp;<code>p<\/code>&nbsp;\u7684&nbsp;<code>prev<\/code>&nbsp;\u548c&nbsp;<code>next<\/code>\uff0c<code>p-&gt;next<\/code>&nbsp;\u6307\u5411&nbsp;<code>3<\/code>\uff0c<code>p-&gt;prev<\/code>&nbsp;\u6307\u5411&nbsp;<code>L<\/code>\u3002<\/li>\n\n\n\n<li>\u66f4\u65b0\u5934\u7ed3\u70b9\u7684&nbsp;<code>next<\/code>&nbsp;\u6307\u5411&nbsp;<code>4<\/code>\uff0c<code>4<\/code>&nbsp;\u7684&nbsp;<code>prev<\/code>&nbsp;\u6307\u5411&nbsp;<code>L<\/code>\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u7ed3\u679c<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u53cd\u8f6c\u540e\u7684\u53cc\u5411\u94fe\u8868&nbsp;<code>L<\/code>\uff1a<code>4 &lt;-&gt; 3 &lt;-&gt; 2 &lt;-&gt; 1<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u5faa\u73af\u94fe\u8868<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\n\/\/ \u5b9a\u4e49\u94fe\u8868\u8282\u70b9\u7684\u6570\u636e\u7c7b\u578b\ntypedef int ElemType;\n\/\/ \u5b9a\u4e49\u5e38\u91cf\n#define OK 1\n#define ERROR 0\n\n\/\/ \u5b9a\u4e49\u5faa\u73af\u94fe\u8868\u7684\u8282\u70b9\u7ed3\u6784\u4f53\ntypedef struct CirNode {\n    ElemType data; \/\/ \u8282\u70b9\u6570\u636e\n    struct CirNode* next; \/\/ \u6307\u5411\u4e0b\u4e00\u4e2a\u8282\u70b9\u7684\u6307\u9488\n} CirNode, * CirLinkList; \/\/ \u522b\u540d\u5b9a\u4e49\n\n\/\/ \u521d\u59cb\u5316\u94fe\u8868\nint InitList(CirLinkList&amp; L) {\n    L = new CirNode; \/\/ \u5206\u914d\u65b0\u7684\u5934\u8282\u70b9\n    L-&gt;data = 0; \/\/ \u5934\u8282\u70b9\u6570\u636e\u521d\u59cb\u5316\u4e3a0\n    L-&gt;next = L; \/\/ \u5934\u8282\u70b9\u6307\u5411\u81ea\u8eab\u5f62\u6210\u5faa\u73af\n    return OK; \/\/ \u8fd4\u56de\u6210\u529f\u6807\u5fd7\n}\n\n\/\/ \u6253\u5370\u94fe\u8868\nvoid PrintList(CirLinkList L) {\n    if (L == NULL || L-&gt;next == L) { \/\/ \u5982\u679c\u94fe\u8868\u4e3a\u7a7a\u6216\u53ea\u6709\u4e00\u4e2a\u5934\u8282\u70b9\n        cout &lt;&lt; \"\u94fe\u8868\u4e3a\u7a7a\" &lt;&lt; endl;\n        return;\n    }\n    CirNode* p = L-&gt;next; \/\/ \u4ece\u7b2c\u4e00\u4e2a\u5b9e\u9645\u8282\u70b9\u5f00\u59cb\n    do {\n        cout &lt;&lt; p-&gt;data &lt;&lt; \" \"; \/\/ \u6253\u5370\u5f53\u524d\u8282\u70b9\u6570\u636e\n        p = p-&gt;next; \/\/ \u79fb\u52a8\u5230\u4e0b\u4e00\u4e2a\u8282\u70b9\n    } while (p != L); \/\/ \u5f53\u56de\u5230\u5934\u8282\u70b9\u65f6\u505c\u6b62\n    cout &lt;&lt; endl; \/\/ \u7ed3\u675f\u6253\u5370\n}\n\n\/\/ \u524d\u63d2\u6cd5\u521b\u5efa\u94fe\u8868\nvoid CreateList_H(CirLinkList&amp; L, int n) {\n    for (int i = 0; i &lt; n; i++) {\n        CirNode* s = new CirNode; \/\/ \u521b\u5efa\u65b0\u8282\u70b9\n        cin &gt;&gt; s-&gt;data; \/\/ \u8f93\u5165\u8282\u70b9\u6570\u636e\n        s-&gt;next = L-&gt;next; \/\/ \u65b0\u8282\u70b9\u63d2\u5165\u5230\u5934\u8282\u70b9\u4e4b\u540e\n        L-&gt;next = s; \/\/ \u66f4\u65b0\u5934\u8282\u70b9\u7684next\u6307\u9488\n    }\n}\n\n\/\/ \u540e\u63d2\u6cd5\u521b\u5efa\u94fe\u8868\nvoid CreateList_R(CirLinkList&amp; L, int n) {\n    CirNode* p = L; \/\/ \u4ece\u5934\u8282\u70b9\u5f00\u59cb\n    for (int i = 0; i &lt; n; i++) {\n        CirNode* s = new CirNode; \/\/ \u521b\u5efa\u65b0\u8282\u70b9\n        cout &lt;&lt; \"\u8bf7\u8f93\u5165\u7b2c\" &lt;&lt; i + 1 &lt;&lt; \"\u4e2a\u5143\u7d20\uff1a\";\n        cin &gt;&gt; s-&gt;data; \/\/ \u8f93\u5165\u8282\u70b9\u6570\u636e\n        p-&gt;next = s; \/\/ \u5c06\u65b0\u8282\u70b9\u94fe\u63a5\u5230\u5f53\u524d\u8282\u70b9\u4e4b\u540e\n        p = s; \/\/ \u79fb\u52a8\u5230\u65b0\u8282\u70b9\n    }\n    p-&gt;next = L; \/\/ \u5f62\u6210\u5faa\u73af\n}\n\n\/\/ \u67e5\u627e\u5143\u7d20\nvoid Find(CirLinkList L, int e) {\n    CirNode* p = L-&gt;next; \/\/ \u4ece\u7b2c\u4e00\u4e2a\u5b9e\u9645\u8282\u70b9\u5f00\u59cb\n    do {\n        if (p-&gt;data == e) { \/\/ \u5982\u679c\u627e\u5230\u76ee\u6807\u5143\u7d20\n            cout &lt;&lt; \"\u627e\u5230\u5143\u7d20\" &lt;&lt; e &lt;&lt; endl;\n            return;\n        }\n        p = p-&gt;next; \/\/ \u79fb\u52a8\u5230\u4e0b\u4e00\u4e2a\u8282\u70b9\n    } while (p != L); \/\/ \u5f53\u56de\u5230\u5934\u8282\u70b9\u65f6\u505c\u6b62\n    cout &lt;&lt; \"\u672a\u627e\u5230\u5143\u7d20\" &lt;&lt; e &lt;&lt; endl; \/\/ \u672a\u627e\u5230\u5219\u8f93\u51fa\u63d0\u793a\n}\n\n\/\/ \u6e05\u7406\u94fe\u8868\nvoid FreeList(CirLinkList&amp; L) {\n    if (L == NULL) return; \/\/ \u5982\u679c\u94fe\u8868\u4e3a\u7a7a\u76f4\u63a5\u8fd4\u56de\n\n    CirNode* current = L-&gt;next; \/\/ \u4ece\u7b2c\u4e00\u4e2a\u5b9e\u9645\u8282\u70b9\u5f00\u59cb\n    CirNode* next; \/\/ \u7528\u4e8e\u4fdd\u5b58\u4e0b\u4e00\u4e2a\u8282\u70b9\u7684\u6307\u9488\n\n    do {\n        next = current-&gt;next; \/\/ \u4fdd\u5b58\u4e0b\u4e00\u4e2a\u8282\u70b9\n        delete current; \/\/ \u5220\u9664\u5f53\u524d\u8282\u70b9\n        current = next; \/\/ \u79fb\u52a8\u5230\u4e0b\u4e00\u4e2a\u8282\u70b9\n    } while (current != L-&gt;next); \/\/ \u5f53\u56de\u5230\u7b2c\u4e00\u4e2a\u5b9e\u9645\u8282\u70b9\u65f6\u505c\u6b62\n\n    delete L; \/\/ \u5220\u9664\u5934\u8282\u70b9\n    L = NULL; \/\/ \u8bbe\u7f6e\u94fe\u8868\u4e3a\u7a7a\n}\n\n\/\/ \u63d2\u5165\u64cd\u4f5c\uff08\u5934\u90e8\uff09\nvoid Insert_H(CirLinkList&amp; L, ElemType e) {\n    CirNode* s = new CirNode; \/\/ \u521b\u5efa\u65b0\u8282\u70b9\n    s-&gt;data = e; \/\/ \u8bbe\u7f6e\u65b0\u8282\u70b9\u6570\u636e\n    if (L == NULL || L-&gt;next == L) { \/\/ \u5982\u679c\u94fe\u8868\u4e3a\u7a7a\u6216\u53ea\u6709\u4e00\u4e2a\u5934\u8282\u70b9\n        L-&gt;next = s; \/\/ \u65b0\u8282\u70b9\u6210\u4e3a\u552f\u4e00\u8282\u70b9\n        s-&gt;next = L; \/\/ \u5f62\u6210\u5faa\u73af\n    }\n    else {\n        s-&gt;next = L-&gt;next; \/\/ \u65b0\u8282\u70b9\u63d2\u5165\u5230\u5934\u8282\u70b9\u4e4b\u540e\n        L-&gt;next = s; \/\/ \u66f4\u65b0\u5934\u8282\u70b9\u7684next\u6307\u9488\n    }\n}\n\n\/\/ \u63d2\u5165\u64cd\u4f5c\uff08\u5c3e\u90e8\uff09\nvoid Insert_T(CirLinkList&amp; L, ElemType e) {\n    CirNode* s = new CirNode; \/\/ \u521b\u5efa\u65b0\u8282\u70b9\n    s-&gt;data = e; \/\/ \u8bbe\u7f6e\u65b0\u8282\u70b9\u6570\u636e\n    if (L == NULL || L-&gt;next == L) { \/\/ \u5982\u679c\u94fe\u8868\u4e3a\u7a7a\u6216\u53ea\u6709\u4e00\u4e2a\u5934\u8282\u70b9\n        L-&gt;next = s; \/\/ \u65b0\u8282\u70b9\u6210\u4e3a\u552f\u4e00\u8282\u70b9\n        s-&gt;next = L; \/\/ \u5f62\u6210\u5faa\u73af\n    }\n    else {\n        CirNode* p = L; \/\/ \u4ece\u5934\u8282\u70b9\u5f00\u59cb\n        while (p-&gt;next != L) { \/\/ \u5bfb\u627e\u6700\u540e\u4e00\u4e2a\u8282\u70b9\n            p = p-&gt;next;\n        }\n        p-&gt;next = s; \/\/ \u5c06\u65b0\u8282\u70b9\u94fe\u63a5\u5230\u6700\u540e\u4e00\u4e2a\u8282\u70b9\u4e4b\u540e\n        s-&gt;next = L; \/\/ \u5f62\u6210\u5faa\u73af\n    }\n}\n\n\/\/ \u63d2\u5165\u64cd\u4f5c\uff08\u4e2d\u95f4\uff09\nvoid Insert_M(CirNode* p, ElemType e) {\n    if (p == NULL) return; \/\/ \u5982\u679c\u6307\u5b9a\u4f4d\u7f6e\u4e3a\u7a7a\u5219\u4e0d\u6267\u884c\n\n    CirNode* s = new CirNode; \/\/ \u521b\u5efa\u65b0\u8282\u70b9\n    s-&gt;data = e; \/\/ \u8bbe\u7f6e\u65b0\u8282\u70b9\u6570\u636e\n    s-&gt;next = p-&gt;next; \/\/ \u65b0\u8282\u70b9\u63d2\u5165\u5230\u6307\u5b9a\u4f4d\u7f6e\u4e4b\u540e\n    p-&gt;next = s; \/\/ \u66f4\u65b0\u524d\u9a71\u8282\u70b9\u7684next\u6307\u9488\n}\n\n\/\/ \u5faa\u73af\u94fe\u8868\u7684\u5f52\u5e76\nCirLinkList MergeList(CirLinkList&amp; La, CirLinkList&amp; Lb) {\n    if (La == NULL || La-&gt;next == La) { \/\/ \u5982\u679cLa\u4e3a\u7a7a\u6216\u53ea\u6709\u4e00\u4e2a\u5934\u8282\u70b9\n        return Lb; \/\/ \u8fd4\u56deLb\n    }\n    if (Lb == NULL || Lb-&gt;next == Lb) { \/\/ \u5982\u679cLb\u4e3a\u7a7a\u6216\u53ea\u6709\u4e00\u4e2a\u5934\u8282\u70b9\n        return La; \/\/ \u8fd4\u56deLa\n    }\n\n    CirNode* p = new CirNode; \/\/ \u521b\u5efa\u65b0\u7684\u5934\u8282\u70b9\n    p-&gt;data = 0; \/\/ \u5934\u8282\u70b9\u6570\u636e\u521d\u59cb\u5316\u4e3a0\n    p-&gt;next = p; \/\/ \u5f62\u6210\u5faa\u73af\n    CirNode* p1 = La-&gt;next; \/\/ La\u7684\u7b2c\u4e00\u4e2a\u5b9e\u9645\u8282\u70b9\n    CirNode* p2 = Lb-&gt;next; \/\/ Lb\u7684\u7b2c\u4e00\u4e2a\u5b9e\u9645\u8282\u70b9\n    CirNode* tail = p; \/\/ \u65b0\u94fe\u8868\u7684\u5c3e\u8282\u70b9\n\n    while (p1 != La &amp;&amp; p2 != Lb) { \/\/ \u904d\u5386\u4e24\u4e2a\u94fe\u8868\n        if (p1-&gt;data &lt;= p2-&gt;data) { \/\/ \u5982\u679cLa\u7684\u8282\u70b9\u5c0f\u4e8e\u7b49\u4e8eLb\u7684\u8282\u70b9\n            tail-&gt;next = p1; \/\/ \u5c06La\u7684\u8282\u70b9\u94fe\u63a5\u5230\u65b0\u94fe\u8868\n            p1 = p1-&gt;next; \/\/ \u79fb\u52a8\u5230La\u7684\u4e0b\u4e00\u4e2a\u8282\u70b9\n        }\n        else {\n            tail-&gt;next = p2; \/\/ \u5c06Lb\u7684\u8282\u70b9\u94fe\u63a5\u5230\u65b0\u94fe\u8868\n            p2 = p2-&gt;next; \/\/ \u79fb\u52a8\u5230Lb\u7684\u4e0b\u4e00\u4e2a\u8282\u70b9\n        }\n        tail = tail-&gt;next; \/\/ \u66f4\u65b0\u65b0\u94fe\u8868\u7684\u5c3e\u8282\u70b9\n    }\n\n    \/\/ \u8fde\u63a5\u5269\u4f59\u7684\u8282\u70b9\n    tail-&gt;next = (p1 != La) ? p1 : p2;\n    while (tail-&gt;next != La &amp;&amp; tail-&gt;next != Lb) {\n        tail = tail-&gt;next;\n    }\n    tail-&gt;next = p; \/\/ \u5f62\u6210\u5faa\u73af\n\n    delete La; \/\/ \u91ca\u653eLa\u7684\u5934\u8282\u70b9\n    delete Lb; \/\/ \u91ca\u653eLb\u7684\u5934\u8282\u70b9\n\n    return p; \/\/ \u8fd4\u56de\u5408\u5e76\u540e\u7684\u94fe\u8868\n}\n\n\/\/ \u5220\u9664\u64cd\u4f5c\nvoid DeleteNode(CirLinkList&amp; L, CirNode* p) {\n    if (p == NULL || p-&gt;next == L) return; \/\/ \u5982\u679c\u6307\u5b9a\u4f4d\u7f6e\u4e3a\u7a7a\u6216\u4e3a\u5934\u8282\u70b9\u5219\u4e0d\u6267\u884c\n\n    CirNode* q = p-&gt;next; \/\/ \u83b7\u53d6\u8981\u5220\u9664\u7684\u8282\u70b9\n    if (q == L) { \/\/ \u5982\u679c\u8981\u5220\u9664\u7684\u662f\u6700\u540e\u4e00\u4e2a\u8282\u70b9\n        while (p-&gt;next != L) { \/\/ \u5bfb\u627e\u5012\u6570\u7b2c\u4e8c\u4e2a\u8282\u70b9\n            p = p-&gt;next;\n        }\n        p-&gt;next = L-&gt;next; \/\/ \u66f4\u65b0\u5012\u6570\u7b2c\u4e8c\u4e2a\u8282\u70b9\u7684next\u6307\u9488\n        delete L; \/\/ \u91ca\u653e\u5934\u8282\u70b9\n        L = p; \/\/ \u66f4\u65b0\u94fe\u8868\u5934\n    }\n    else {\n        p-&gt;next = q-&gt;next; \/\/ \u66f4\u65b0\u524d\u9a71\u8282\u70b9\u7684next\u6307\u9488\n        delete q; \/\/ \u91ca\u653e\u88ab\u5220\u9664\u8282\u70b9\n    }\n}\n\nint main() {\n    CirLinkList L = NULL; \/\/ \u521d\u59cb\u5316\u4e3b\u94fe\u8868\n    int choice, n, e, i;\n    CirNode* p;\n\n    while (true) {\n        cout &lt;&lt; \"\\n\u8bf7\u9009\u62e9\u64cd\u4f5c\uff1a\" &lt;&lt; endl;\n        cout &lt;&lt; \"1. \u521d\u59cb\u5316\u94fe\u8868\" &lt;&lt; endl;\n        cout &lt;&lt; \"2. \u524d\u63d2\u6cd5\u521b\u5efa\u94fe\u8868\" &lt;&lt; endl;\n        cout &lt;&lt; \"3. \u540e\u63d2\u6cd5\u521b\u5efa\u94fe\u8868\" &lt;&lt; endl;\n        cout &lt;&lt; \"4. \u6253\u5370\u94fe\u8868\" &lt;&lt; endl;\n        cout &lt;&lt; \"5. \u67e5\u627e\u5143\u7d20\" &lt;&lt; endl;\n        cout &lt;&lt; \"6. \u63d2\u5165\u8282\u70b9\uff08\u5934\u90e8\uff09\" &lt;&lt; endl;\n        cout &lt;&lt; \"7. \u63d2\u5165\u8282\u70b9\uff08\u5c3e\u90e8\uff09\" &lt;&lt; endl;\n        cout &lt;&lt; \"8. \u63d2\u5165\u8282\u70b9\uff08\u4e2d\u95f4\uff09\" &lt;&lt; endl;\n        cout &lt;&lt; \"9. \u5f52\u5e76\u94fe\u8868\" &lt;&lt; endl;\n        cout &lt;&lt; \"10. \u5220\u9664\u8282\u70b9\" &lt;&lt; endl;\n        cout &lt;&lt; \"11. \u9000\u51fa\" &lt;&lt; endl;\n        cout &lt;&lt; \"\u8f93\u5165\u9009\u9879: \";\n        cin &gt;&gt; choice;\n\n        switch (choice) {\n        case 1:\n            InitList(L);\n            cout &lt;&lt; \"\u94fe\u8868\u5df2\u521d\u59cb\u5316\" &lt;&lt; endl;\n            break;\n        case 2:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u521b\u5efa\u7684\u8282\u70b9\u6570: \";\n            cin &gt;&gt; n;\n            CreateList_H(L, n);\n            break;\n        case 3:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u521b\u5efa\u7684\u8282\u70b9\u6570: \";\n            cin &gt;&gt; n;\n            CreateList_R(L, n);\n            break;\n        case 4:\n            PrintList(L);\n            break;\n        case 5:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u67e5\u627e\u7684\u5143\u7d20: \";\n            cin &gt;&gt; e;\n            Find(L, e);\n            break;\n        case 6:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u63d2\u5165\u7684\u5143\u7d20: \";\n            cin &gt;&gt; e;\n            Insert_H(L, e);\n            break;\n        case 7:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u63d2\u5165\u7684\u5143\u7d20: \";\n            cin &gt;&gt; e;\n            Insert_T(L, e);\n            break;\n        case 8:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u63d2\u5165\u7684\u4f4d\u7f6e (\u8282\u70b9\u6570\u636e): \";\n            cin &gt;&gt; e;\n            p = L;\n            while (p-&gt;next != L &amp;&amp; p-&gt;next-&gt;data != e) {\n                p = p-&gt;next;\n            }\n            if (p-&gt;next != L) {\n                cout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u63d2\u5165\u7684\u5143\u7d20: \";\n                cin &gt;&gt; e;\n                Insert_M(p, e);\n            }\n            else {\n                cout &lt;&lt; \"\u672a\u627e\u5230\u6307\u5b9a\u4f4d\u7f6e\" &lt;&lt; endl;\n            }\n            break;\n        case 9: {\n            CirLinkList Lb = NULL;\n            InitList(Lb); \/\/ \u786e\u4fdd Lb \u88ab\u521d\u59cb\u5316\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u94fe\u8868\u7684\u8282\u70b9\u6570: \";\n            cin &gt;&gt; n;\n            CreateList_R(Lb, n);\n            L = MergeList(L, Lb);\n            cout &lt;&lt; \"\u94fe\u8868\u5df2\u5f52\u5e76\" &lt;&lt; endl;\n            break;\n        }\n        case 10:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u8981\u5220\u9664\u7684\u4f4d\u7f6e (\u8282\u70b9\u6570\u636e): \";\n            cin &gt;&gt; e;\n            p = L;\n            while (p-&gt;next != L &amp;&amp; p-&gt;next-&gt;data != e) {\n                p = p-&gt;next;\n            }\n            if (p-&gt;next != L) {\n                DeleteNode(L, p);\n            }\n            else {\n                cout &lt;&lt; \"\u672a\u627e\u5230\u6307\u5b9a\u4f4d\u7f6e\" &lt;&lt; endl;\n            }\n            break;\n        case 11:\n            FreeList(L);\n            return 0;\n        default:\n            cout &lt;&lt; \"\u65e0\u6548\u7684\u9009\u62e9\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\" &lt;&lt; endl;\n        }\n    }\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u5faa\u73af\u94fe\u8868\u57fa\u672c\u64cd\u4f5c\uff0c\u8fd9\u4e2a\u5199\u7684\u66f4\u7b80\u5355\uff0c\u751a\u81f3\u8fde\u4e00\u70b9\u5065\u58ee\u6027\u90fd\u6ca1\u52a0\uff0c\u4f46\u662f\u91cc\u9762\u7684\u6b65\u9aa4\u57fa\u672c\u90fd\u52a0\u4e0a\u6ce8\u91ca\u4e86\u3002\u5269\u4e0b\u7684\u91cc\u9762\u96be\u61c2\u7684\u64cd\u4f5c\u7b49\u6211\u6709\u7a7a\u518d\u8865\u5145\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5199\u5728\u6700\u540e<\/h2>\n\n\n\n<p>\u94fe\u8868\u6bd4\u987a\u5e8f\u8868\u96be\u5199\u4e0d\u5c11\uff0c\u65ad\u65ad\u7eed\u7eed\u5199\u4e86\u4e09\u5929\u624d\u5dee\u4e0d\u591a\u5199\u5b8c\uff0c\u91cc\u9762\u8fd8\u6709\u4e0d\u5c11\u4f8b\u5b50\u4ec0\u4e48\u7684\u6ca1\u8865\u5145\uff0c\u7b49\u6211\u7f13\u7f13\u518d\u66f4\u65b0\u3002\u8fd9\u7bc7\u6587\u7ae0\u524d\u524d\u540e\u540e\u5df2\u7ecf\u4fee\u6539\u4e86\u4e8c\u5341\u591a\u6b21\u4e86\uff0c\u57fa\u672c\u4e0a\u662f\u628a\u7ebf\u6027\u8868\u7684\u94fe\u5f0f\u7ed3\u6784\u90fd\u5199\u51fa\u6765\u4e86\uff0c\u622a\u6b62\u5230\u76ee\u524d\uff0c\u53cc\u5411\u94fe\u8868\u8fd8\u662f\u4e0d\u592a\u5168\u9762\uff0c\u4f46\u53ef\u80fd\u4e0d\u4f1a\u518d\u8003\u8651\u8865\u5145\uff0c\u5faa\u73af\u94fe\u8868\u4e5f\u5c31\u63d0\u4e86\u70b9\u6982\u5ff5\u6027\u7684\u4e1c\u897f\uff0c\u5177\u4f53\u64cd\u4f5c\u6ca1\u6709\u7f57\u5217\u51fa\u6765\uff0c\u4ee5\u540e\u53ef\u80fd\u4f1a\u5199\u51fa\u6765\u3002\u5148\u5199\u5230\u8fd9\u54272024\/09\/29\u3002\u5728\u8fdb\u884c\u64cd\u4f5c\u7684\u65f6\u5019\u53d1\u73b0\u53cc\u5411\u94fe\u8868\u7684\u4f8b\u5b50\u5c11\u4e86\u521b\u5efa\uff0c\u8865\u4e86\u4e00\u4e0b2024\/10\/07\u3002\u8865\u5145\u4e86\u5faa\u73af\u94fe\u8868\u7684\u64cd\u4f5c\u4f8b\u5b502024\/10\/16<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u597d\u7684\uff0c\u4e00\u523b\u4e5f\u6ca1\u6709\u4e3a\u4e86\u987a\u5e8f\u8868\u7684\u5b66\u4e60\u7ed3\u675f\u800c\u611f\u5230\u56de\u5473\u65e0\u7a77\uff0c\u63a5\u4e0b\u6765\u8ba9\u6211\u4eec\u6709\u8bf7\u4e0b\u4e00\u4e2a\u9009\u624b\u2014\u2014\u94fe\u8868\u7684\u767b\u573a\u3002 \u540c\u4e3a\u7ebf\u6027\u7ed3\u6784\u7684\u94fe\u8868\u4e0e\u987a\u5e8f\u8868\u4e4b &#8230;<\/p>\n","protected":false},"author":1,"featured_media":197,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,17],"tags":[11,18,19,20],"class_list":["post-169","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","category-17","tag-c","tag-18","tag-19","tag-20"],"_links":{"self":[{"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts\/169"}],"collection":[{"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/comments?post=169"}],"version-history":[{"count":31,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts\/169\/revisions"}],"predecessor-version":[{"id":248,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts\/169\/revisions\/248"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/media\/197"}],"wp:attachment":[{"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/media?parent=169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/categories?post=169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/tags?post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}