{"id":123,"date":"2024-09-15T15:47:45","date_gmt":"2024-09-15T07:47:45","guid":{"rendered":"https:\/\/www.xxinran.tech\/?p=123"},"modified":"2024-09-25T23:44:15","modified_gmt":"2024-09-25T15:44:15","slug":"c%e8%af%ad%e8%a8%80%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84-%e9%a1%ba%e5%ba%8f%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/www.xxinran.tech\/index.php\/2024\/09\/15\/c%e8%af%ad%e8%a8%80%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84-%e9%a1%ba%e5%ba%8f%e8%a1%a8\/","title":{"rendered":"C\u8bed\u8a00\u6570\u636e\u7ed3\u6784\u2014\u2014\u987a\u5e8f\u8868"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u524d\u8a00<\/h2>\n\n\n\n<p>\u8fd9\u662fC\u8bed\u8a00\u6570\u636e\u7ed3\u6784\u4e2d\u6700\u7b80\u5355\u7684\u987a\u5e8f\u8868\uff0c\u9700\u8981\u6709\u6307\u9488\u548c\u7ed3\u6784\u4f53\u7684\u57fa\u7840\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4f1a\u5c3d\u53ef\u80fd\u4ee5\u6211\u7684\u7406\u89e3\u518d\u914d\u4e0a\u4e00\u4e9b\u8f83\u4e3a\u5b98\u65b9\u7684\u89e3\u91ca\u6765\u4f7f\u770b\u8fd9\u7bc7\u6587\u7ae0\u7684\u4eba\u80fd\u591f\u7406\u89e3\u987a\u5e8f\u8868\u3002<\/p>\n\n\n\n<p>\u5199\u8fd9\u7bc7\u6587\u7ae0\u4e5f\u662f\u56e0\u4e3a\u6211\u5728\u5b66\u6821\u5b66\u4e60C\u8bed\u8a00\u6570\u636e\u7ed3\u6784\u7684\u65f6\u5019\uff0c\u56e0\u4e3a\u8f83\u957f\u65f6\u95f4\u6ca1\u6709\u6572\u8fc7C\u8bed\u8a00\u4e86\uff0c\u6240\u4ee5\u524d\u4e00\u4e24\u8282\u8bfe\u542c\u7740\u6709\u70b9\u61f5\u5708\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ecb\u7ecd<\/h2>\n\n\n\n<p>\u6309\u7167\u767e\u5ea6\u767e\u79d1\u7684\u89e3\u91ca\uff0c\u987a\u5e8f\u8868\u5c31\u662f\u5728\u8ba1\u7b97\u673a\u5185\u5b58\u4e2d\u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u4fdd\u5b58\u7684\u7ebf\u6027\u8868\uff0c\u5e76\u4e14\u987a\u5e8f\u8868\u662f\u91c7\u7528\u987a\u5e8f\u5b58\u50a8\u7ed3\u6784\u7684\u7ebf\u6027\u8868\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u4ec0\u4e48\u662f\u7ebf\u6027\u8868\u5462\uff1f\u6211\u5728\u4e4b\u524d\u7684\u6587\u7ae0\u4e2d\u8bb2\u8fc7\uff0c\u4e0d\u61c2\u7684\u53ef\u4ee5\u53bb\u770b\u4e00\u770b\u3002<\/p>\n\n\n\n<p>\u6216\u8005\u8fd9\u4e48\u8bf4\uff0c\u7ebf\u6027\u8868\u7684\u987a\u5e8f\u5b58\u50a8\u7ed3\u6784\u53c8\u79f0\u4e3a\u987a\u5e8f\u8868\u3002\u5b83\u662f\u7528\u4e00\u7ec4\u5730\u5740\u8fde\u7eed\u7684\u5b58\u50a8\u5355\u5143\u4f9d\u6b21\u5b58\u50a8\u7ebf\u6027\u8868\u4e2d\u7684\u6570\u636e\u5143\u7d20\uff0c\u4ece\u800c\u4f7f\u5f97\u903b\u8f91\u4e0a\u76f8\u90bb\u7684\u4e24\u4e2a\u5143\u7d20\u5728\u7269\u7406\u4f4d\u7f6e\u4e0a\u4e5f\u76f8\u90bb\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e3e\u4f8b\u8bf4\u660e<\/h3>\n\n\n\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u73ed\u7ea7\uff0c\u8be5\u73ed\u7ea7\u4e2d\u6709n\u540d\u5b66\u751f\uff0c\u6bcf\u4e2a\u5b66\u751f\u90fd\u6709\u552f\u4e00\u7684\u5b66\u53f7\u3002\u5982\u679c\u6211\u4eec\u6309\u7167\u5b66\u53f7\u7684\u5347\u5e8f\u5bf9\u5b66\u751f\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u5c06\u6392\u5e8f\u540e\u7684\u5b66\u751f\u4fe1\u606f\u5b58\u50a8\u5728\u4e00\u4e2a\u987a\u5e8f\u8868\u4e2d\uff0c\u90a3\u4e48\u53ef\u4ee5\u60f3\u8c61\u8fd9\u4e2a\u987a\u5e8f\u8868\u662f\u4e00\u4e2a\u6570\u7ec4\u3002\u5728\u8fd9\u4e2a\u6570\u7ec4\u4e2d\uff0c\u5b66\u53f7\u6700\u5c0f\u7684\u5b66\u751f\u5c06\u4f4d\u4e8e\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\uff08\u5373\u7d22\u5f150\uff09\uff0c\u5b66\u53f7\u7b2c\u4e8c\u5c0f\u7684\u5b66\u751f\u7d27\u968f\u5176\u540e\uff0c\u4f9d\u6b64\u7c7b\u63a8\uff0c\u76f4\u5230\u6700\u540e\u4e00\u4e2a\u5b66\u751f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7269\u7406\u4f4d\u7f6e\u4e0e\u903b\u8f91\u4f4d\u7f6e\u7684\u5173\u7cfb<\/h3>\n\n\n\n<p>\u5728\u8fd9\u6837\u7684\u987a\u5e8f\u8868\u4e2d\uff0c\u5982\u679c\u6211\u4eec\u8981\u627e\u5230\u67d0\u4e2a\u7279\u5b9a\u5b66\u53f7\u7684\u5b66\u751f\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u8ba1\u7b97\u51fa\u8be5\u5b66\u751f\u5728\u6570\u7ec4\u4e2d\u7684\u7d22\u5f15\u4f4d\u7f6e\uff0c\u800c\u4e0d\u9700\u8981\u4ece\u5934\u5f00\u59cb\u9010\u4e2a\u6bd4\u8f83\u3002\u6bd4\u5982\uff0c\u5982\u679c\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\uff08\u7d22\u5f150\uff09\u5bf9\u5e94\u5b66\u53f7\u4e3a1\u7684\u5b66\u751f\uff0c\u90a3\u4e48\u5b66\u53f7\u4e3ak\u7684\u5b66\u751f\u5c06\u4f1a\u51fa\u73b0\u5728\u6570\u7ec4\u7684\u7b2c(k-1)\u4e2a\u4f4d\u7f6e\uff08\u56e0\u4e3a\u6570\u7ec4\u7d22\u5f15\u662f\u4ece0\u5f00\u59cb\u7684\uff09\u3002<\/p>\n\n\n\n<p>\u9644\u4e00\u4e2a\u56fe\u7247\u89e3\u91ca<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/s21.ax1x.com\/2024\/09\/15\/pAu34SA.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u5047\u8bbe\u7ebf\u6027\u8868\u6700\u5927\u4e3aMaxsize\uff0c\u8d77\u59cb\u4f4d\u7f6e\u4e3aLOC(A)\uff0csizeof(ElemType)\u4e3a\u5355\u4e2a\u5143\u7d20\u6240\u5360\u7528\u7684\u5185\u5b58\u5927\u5c0f\uff0c\u987a\u5e8f\u8868a1\uff0ca2\u4fbf\u662f\u5b66\u53f7\u4e3a1\u7684\u5b66\u751f\u548c\u5b66\u53f7\u4e3a2\u7684\u5b66\u751f\uff0c\u5b66\u751f\u5bf9\u5e94\u7684\u5185\u5b58\u5730\u5740\u5373\u4e3a\u8fde\u7eed\u7684LOC(A),LOC(A)+sizeof(ElemType)\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u7684\u5b58\u50a8\u7ed3\u6784<\/h2>\n\n\n\n<p>\u5047\u5b9a\u7ebf\u6027\u8868\u7684\u6570\u636e\u7c7b\u578b\u4e3aElemType\uff0c\u5219\u7ebf\u6027\u8868\u7684\u5b58\u50a8\u7c7b\u578b\u63cf\u8ff0\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define Maxsize 50    \/\/\u7ebf\u6027\u8868\u6700\u5927\u957f\u5ea6\ntypedef struct{\n    ElemType elem&#91;Maxsize];    \/\/\u987a\u5e8f\u8868\u7684\u5143\u7d20\n    int length;            \/\/\u987a\u5e8f\u8868\u5f53\u524d\u957f\u5ea6\n}SqList;            \/\/\u987a\u5e8f\u8868\u7684\u5b9a\u4e49\u7c7b\u578b<\/code><\/pre>\n\n\n\n<p>\u5176\u4e2dElemType\u6570\u636e\u7c7b\u578b\u662f\u4e3a\u4e86\u63cf\u8ff0\u7edf\u4e00\u800c\u81ea\u5b9a\u7684\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u8981\u5177\u4f53\u5b9a\u4e49\u8868\u4e2d\u7684\u6570\u636e\u7c7b\u578b\uff0c\u65e2\u53ef\u4ee5\u662f\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff0c\u5982int\u3001float\u3001char\u7b49\uff0c\u4e5f\u53ef\u4ee5\u662f\u6784\u9020\u6570\u636e\u7c7b\u578b\uff0c\u5982struct\u7ed3\u6784\u4f53\u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u4e3e\u4e00\u4e2a\u7ed3\u6784\u4f53\u7c7b\u578b\u7684\u4f8b\u5b50<\/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>\u8fd9\u91cc\u6211\u5b9a\u4e49\u4e86\u4e00\u4e2a\u56fe\u4e66\u7684\u7ed3\u6784\u4f53\uff0c\u91cc\u9762\u5305\u542b\u4e86\u4e66\u7684\u6807\u53f7\uff0c\u4e66\u7684\u4e66\u540d\u4ee5\u53ca\u4e66\u7684\u4ef7\u683c\uff0c\u63a5\u4e0b\u6765\u8981\u63cf\u8ff0\u987a\u5e8f\u8868\u5219\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define Maxsize 50    \/\/\u7ebf\u6027\u8868\u6700\u5927\u957f\u5ea6\ntypedef struct {\n\tBook elem&#91;Maxsize];\/\/\u987a\u5e8f\u8868\u7684\u5143\u7d20 \n\tint length;\/\/\u5f53\u524d\u56fe\u4e66\u6570\u91cf\n}SqList;\n<\/code><\/pre>\n\n\n\n<p>\u8fd9\u76f8\u5f53\u4e8e\u662f\u628a\u56fe\u4e66\u8fd9\u4e2a\u7ed3\u6784\u4f53\u6574\u4f53\u7684\u653e\u5165\u4e86\u201c\u6570\u7ec4\u201d\u4e4b\u4e2d\uff0c\u5177\u4f53\u5982\u56fe\u6240\u793a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/s21.ax1x.com\/2024\/09\/15\/pAuYa0x.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u56fe\u4e2d\u53ef\u4ee5\u770b\u5f97\u51fa\u6765\u987a\u5e8f\u8868\u5c31\u662f\u6570\u7ec4\uff0c\u5176\u4e2d\u7684a1\uff0ca2......\u90fd\u662f\u6570\u7ec4\u91cc\u9762\u7684\u6570\u636e\u5143\u7d20\uff0c\u56e0\u4e3a\u6211\u5b9a\u4e49\u7684\u6570\u636e\u7c7b\u578b\u662f\u7ed3\u6784\u4f53\u7c7b\u578bBook\uff0c\u76f8\u5f53\u4e8e\u628a\u7ed3\u6784\u4f53\u5b58\u50a8\u5230\u6570\u7ec4\u4e4b\u4e2d\uff0c\u6240\u4ee5\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u6570\u636e\u5143\u7d20\u76f8\u5f53\u4e8e\u7ed3\u6784\u4f53Book\uff0c\u6709\u6211\u5b9a\u4e49\u7684\u201c\u6807\u53f7\u3001\u4e66\u540d\u3001\u4ef7\u683c\u201d\u8fd9\u4e9b\u4fe1\u606f\u3002<\/p>\n\n\n\n<p>\u6570\u7ec4\u53ef\u4ee5\u662f\u9759\u6001\u5206\u914d\u7684\uff0c\u4e5f\u53ef\u4ee5\u662f\u52a8\u6001\u5206\u914d\u7684\u3002\u5728\u9759\u6001\u5206\u914d\u65f6\uff0c\u7531\u4e8e\u6570\u7ec4\u7684\u5927\u5c0f\u548c\u7a7a\u95f4\u4e8b\u5148\u5df2\u7ecf\u56fa\u5b9a\uff0e\u4e00\u65e6\u7a7a\u95f4\u5360\u6ee1\uff0c\u518d\u52a0\u5165\u65b0\u7684\u6570\u636e\u5c31\u4f1a\u4ea7\u751f\u6ea2\u51fa\uff0c\u8fdb\u800c\u5bfc\u81f4\u7a0b\u5e8f\u5d29\u6e83\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define Maxsize 50    \/\/\u7ebf\u6027\u8868\u6700\u5927\u957f\u5ea6\ntypedef struct{\n    ElemType elem&#91;Maxsize];    \/\/\u987a\u5e8f\u8868\u7684\u5143\u7d20\n    int length;            \/\/\u987a\u5e8f\u8868\u5f53\u524d\u957f\u5ea6\n}SqList;            \/\/\u987a\u5e8f\u8868\u7684\u5b9a\u4e49\u7c7b\u578b\n<\/code><\/pre>\n\n\n\n<p>\u5728\u4e0a\u9762\u7684\u63cf\u8ff0\u4e2d\uff0c\u6211\u4f7f\u7528\u7684\u662f\u9759\u6001\u5206\u914d\uff0c\u56e0\u4e3a\u6570\u7ec4 elem \u7684\u5927\u5c0f\u7531\u9884\u5904\u7406\u5b8f <code>Maxsize<\/code> \u5b9a\u4e49\uff0c\u9ed8\u8ba4\u4e3a 50\uff0c\u8fd9\u610f\u5473\u7740 elem \u80fd\u591f\u5b58\u50a8\u7684\u6700\u5927\u5143\u7d20\u6570\u91cf\u662f\u56fa\u5b9a\u7684\uff0c\u4e0d\u4f1a\u968f\u7740\u5b9e\u9645\u5b58\u50a8\u6570\u636e\u7684\u53d8\u5316\u800c\u52a8\u6001\u8c03\u6574\u3002<\/p>\n\n\n\n<p>\u800c\u5728\u52a8\u6001\u5206\u914d\u65f6\uff0c\u5b58\u50a8\u6570\u7ec4\u7684\u7a7a\u95f4\u662f\u5728\u7a0b\u5e8f\u6267\u884c\u8fc7\u7a0b\u4e2d\u901a\u8fc7\u52a8\u6001\u5b58\u50a8\u5206\u914d\u8bed\u53e5\u5206\u914d\u7684\uff0c\u4e00\u65e6\u6570\u636e\u7a7a\u95f4\u5360\u6ee1\uff0c\u5c31\u53e6\u5916\u5f00\u8f9f\u4e00\u5757\u66f4\u5927\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u7528\u4ee5\u66ff\u6362\u539f\u6765\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u4ece\u800c\u8fbe\u5230\u6269\u5145\u5b58\u50a8\u6570\u7ec4\u7a7a\u753b\u7684\u76ee\u7684\uff0c\u800c\u4e0d\u9700\u8981\u4e3a\u7ebf\u6027\u8868\u4e00\u6b21\u6027\u5730\u5212\u5206\u6240\u6709\u7a7a\u95f4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define InitSize 100    \/\/\u7ebf\u6027\u8868\u7684\u521d\u59cb\u957f\u5ea6\ntypedef struct{\n    ElemType *elem;    \/\/\u5b58\u50a8\u7a7a\u95f4\u7684\u57fa\u5730\u5740\n    int MaxSize,length;            \/\/\u987a\u5e8f\u8868\u5f53\u524d\u6700\u5927\u5bb9\u91cf\u548c\u957f\u5ea6\n}SqList;            \/\/\u987a\u5e8f\u8868\u7684\u5b9a\u4e49<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u8865\u5145\u4e00\u4e0b\uff0c\u57fa\u5730\u5740\u6307\u7684\u662f\u8fd9\u4e9b\u6570\u636e\u7ed3\u6784\u5728\u5185\u5b58\u4e2d\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002\u5bf9\u4e8e\u6570\u7ec4\u6765\u8bf4\uff0c\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u5730\u5740\u5c31\u662f\u6570\u7ec4\u7684\u57fa\u5730\u5740\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">C\u8bed\u8a00\u7684\u52a8\u6001\u5206\u914d\u5185\u5b58<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>L.elem = (ElemType*)malloc(sizeof(ElemType)*InitSize);<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>malloc(sizeof(ElemType) * InitSize)<\/code>&nbsp;\u8fd9\u90e8\u5206\u4f1a\u8bf7\u6c42\u64cd\u4f5c\u7cfb\u7edf\u5206\u914d\u4e00\u6bb5\u8fde\u7eed\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u5176\u5927\u5c0f\u4e3a&nbsp;<code>InitSize<\/code>&nbsp;\u4e2a&nbsp;<code>ElemType<\/code>&nbsp;\u7c7b\u578b\u7684\u6570\u636e\u6240\u5360\u7684\u5b57\u8282\u6570\u3002<\/li>\n\n\n\n<li><code>(ElemType*)<\/code>&nbsp;\u662f\u7c7b\u578b\u8f6c\u6362\uff0c\u786e\u4fdd\u8fd4\u56de\u7684\u6307\u9488\u7c7b\u578b\u662f&nbsp;<code>ElemType<\/code>&nbsp;\u7c7b\u578b\u7684\u6307\u9488\u3002<\/li>\n\n\n\n<li><code>L.elem = ...<\/code>&nbsp;\u5c06\u5206\u914d\u5f97\u5230\u7684\u5185\u5b58\u5730\u5740\u8d4b\u503c\u7ed9&nbsp;<code>L<\/code>.<code>elem<\/code>&nbsp;\u6210\u5458\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">C++\u52a8\u6001\u5206\u914d\u5185\u5b58<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>L.elem =  new ElemType&#91;InitSize];<\/code><\/pre>\n\n\n\n<p><strong>\u6ce8\u610f:<\/strong>\u52a8\u6001\u5206\u914d\u5e76\u4e0d\u662f\u94fe\u5f0f\u5b58\u50a8\u3001\u5b83\u540c\u6837\u5c45\u4e8e\u987a\u5e8f\u5b58\u50a8\u7ed3\u6784\uff0c\u7269\u7406\u7ed3\u6784\u6ca1\u6709\u53d8\u5316\uff0c\u4f9d\u7136\u662f\u968f\u673a\u5b58\u53d6\u65b9\u5f0f\uff0c\u53ea\u662f\u5206\u914d\u7684\u7a7a\u95f4\u5927\u5c0f\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u51b3\u5b9a\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u7684\u7279\u70b9<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u8fde\u7eed\u5b58\u50a8<\/strong>\uff1a \u987a\u5e8f\u8868\u4e2d\u7684\u6240\u6709\u5143\u7d20\u90fd\u5b58\u50a8\u5728\u4e00\u4e2a\u8fde\u7eed\u7684\u5185\u5b58\u533a\u57df\u4e2d\u3002\u8fd9\u610f\u5473\u7740\u53ef\u4ee5\u901a\u8fc7\u8ba1\u7b97\u504f\u79fb\u91cf\u5feb\u901f\u8bbf\u95ee\u4efb\u4f55\u5143\u7d20\uff0c\u4ece\u800c\u5b9e\u73b0\u968f\u673a\u8bbf\u95ee\u3002<\/li>\n\n\n\n<li><strong>\u968f\u673a\u8bbf\u95ee<\/strong>\uff1a \u7531\u4e8e\u5143\u7d20\u662f\u8fde\u7eed\u5b58\u50a8\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528\u7d22\u5f15\u5feb\u901f\u8bbf\u95ee\u4efb\u4f55\u4e00\u4e2a\u5143\u7d20\u3002\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(1)\uff0c\u5373\u5e38\u6570\u65f6\u95f4\u590d\u6742\u5ea6\u3002<\/li>\n\n\n\n<li><strong>\u56fa\u5b9a\u5927\u5c0f<\/strong>\uff1a \u4e00\u65e6\u521b\u5efa\uff0c\u987a\u5e8f\u8868\u7684\u5927\u5c0f\u901a\u5e38\u662f\u56fa\u5b9a\u7684\uff08\u9664\u975e\u4f7f\u7528\u52a8\u6001\u6570\u7ec4\uff09\u3002\u5982\u679c\u9700\u8981\u5b58\u50a8\u7684\u6570\u636e\u91cf\u8d85\u8fc7\u9884\u5b9a\u7684\u5927\u5c0f\uff0c\u5c31\u9700\u8981\u91cd\u65b0\u5206\u914d\u4e00\u5757\u66f4\u5927\u7684\u5185\u5b58\u533a\u57df\uff0c\u5e76\u590d\u5236\u539f\u6709\u6570\u636e\u8fc7\u53bb\u3002<\/li>\n\n\n\n<li><strong>\u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c\u7684\u6210\u672c<\/strong>\uff1a \u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c\u901a\u5e38\u6bd4\u8f83\u8017\u65f6\uff0c\u5c24\u5176\u662f\u5f53\u63d2\u5165\u6216\u5220\u9664\u53d1\u751f\u5728\u4e2d\u95f4\u4f4d\u7f6e\u65f6\u3002\u4e3a\u4e86\u4fdd\u6301\u5143\u7d20\u7684\u8fde\u7eed\u5b58\u50a8\u7279\u6027\uff0c\u53ef\u80fd\u9700\u8981\u79fb\u52a8\u5927\u91cf\u7684\u5143\u7d20\u3002\u6700\u574f\u60c5\u51b5\u4e0b\uff0c\u63d2\u5165\u6216\u5220\u9664\u64cd\u4f5c\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(n)\uff0c\u5176\u4e2d n \u662f\u8868\u4e2d\u7684\u5143\u7d20\u6570\u91cf\u3002<\/li>\n\n\n\n<li><strong>\u6613\u4e8e\u5b9e\u73b0<\/strong>\uff1a \u987a\u5e8f\u8868\u57fa\u4e8e\u6570\u7ec4\u5b9e\u73b0\uff0c\u6240\u4ee5\u5176\u5b9e\u73b0\u76f8\u5bf9\u7b80\u5355\u3002\u6570\u7ec4\u672c\u8eab\u5c31\u662f\u5927\u591a\u6570\u7f16\u7a0b\u8bed\u8a00\u63d0\u4f9b\u7684\u57fa\u672c\u6570\u636e\u7c7b\u578b\u4e4b\u4e00\u3002<\/li>\n\n\n\n<li><strong>\u7a7a\u95f4\u5229\u7528\u7387<\/strong>\uff1a \u7531\u4e8e\u987a\u5e8f\u8868\u7684\u5927\u5c0f\u662f\u56fa\u5b9a\u7684\uff0c\u6240\u4ee5\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u4f1a\u5b58\u5728\u7a7a\u95f4\u6d6a\u8d39\u3002\u4f8b\u5982\uff0c\u5982\u679c\u9884\u5148\u5206\u914d\u7684\u7a7a\u95f4\u5927\u4e8e\u5b9e\u9645\u4f7f\u7528\u7684\u7a7a\u95f4\uff0c\u5c31\u4f1a\u9020\u6210\u5185\u5b58\u7a7a\u95f4\u7684\u6d6a\u8d39\u3002<\/li>\n\n\n\n<li><strong>\u5185\u5b58\u7ba1\u7406<\/strong>\uff1a \u987a\u5e8f\u8868\u53ef\u4ee5\u4f7f\u7528\u9759\u6001\u6570\u7ec4\u5b9e\u73b0\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u52a8\u6001\u5185\u5b58\u5206\u914d\u6765\u5b9e\u73b0\u3002\u9759\u6001\u6570\u7ec4\u7684\u5927\u5c0f\u5728\u7f16\u8bd1\u65f6\u786e\u5b9a\uff0c\u800c\u52a8\u6001\u6570\u7ec4\u5141\u8bb8\u5728\u8fd0\u884c\u65f6\u6839\u636e\u9700\u8981\u8c03\u6574\u5927\u5c0f\u3002<\/li>\n\n\n\n<li><strong>\u8f85\u52a9\u64cd\u4f5c\u7b80\u5355<\/strong>\uff1a \u83b7\u53d6\u987a\u5e8f\u8868\u7684\u957f\u5ea6\u3001\u5224\u65ad\u662f\u5426\u4e3a\u7a7a\u7b49\u64cd\u4f5c\u90fd\u975e\u5e38\u7b80\u5355\uff0c\u901a\u5e38\u53ea\u9700\u8981\u8bfb\u53d6\u8bb0\u5f55\u5f53\u524d\u5143\u7d20\u6570\u91cf\u7684\u53d8\u91cf\u5373\u53ef\u3002<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u7684\u57fa\u672c\u64cd\u4f5c<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u521d\u59cb\u5316\u987a\u5e8f\u8868<\/h3>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<p>\u2460\u4e3a\u987a\u5e8f\u8868L\u52a8\u6001\u5206\u914d\u4e00\u4e2a\u9884\u5b9a\u5927\u5c0f\u7684\u6570\u7ec4\u7a7a\u95f4\uff0c\u4f7felem\u6307\u5411\u8fd9\u6bb5\u7a7a\u95f4\u7684\u57fa\u5730\u5740\u3002<br>\u2461\u5c06\u8868\u7684\u5f53\u524d\u957f\u5ea6\u8bbe\u4e3a0\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int InitList(SqList&amp; L) { \/\/L\u672c\u8eab\u8981\u53d1\u751f\u6539\u53d8\uff0c\u6240\u4ee5\u7528\u5f15\u7528\u578b\n\tL.elem = new ElemType&#91;100];\n\tif (L.elem == NULL) {\n\t\treturn ERROR;\n\t}\n\tL.length = 0;\n\treturn OK;\n}\n<\/code><\/pre>\n\n\n\n<p>\u52a8\u6001\u5206\u914d\u7ebf\u6027\u8868\u7684\u5b58\u50a8\u533a\u57df\u53ef\u4ee5\u66f4\u6709\u6548\u5730\u5229\u7528\u7cfb\u7edf\u7684\u8d44\u6e90\uff0c\u5f53\u4e0d\u9700\u8981\u8be5\u7ebf\u6027\u8868\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u9500\u6bc1\u64cd\u4f5c\u53ca\u65f6\u91ca\u653e\u5360\u7528\u7684\u5b58\u50a8\u7a7a\u95f4\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u7684\u53d6\u503c<\/h3>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u5224\u65ad\u6307\u5b9a\u7684\u4f4d\u7f6e\u5e8f\u53f7 i \u503c\u662f\u5426\u5408\u7406\uff081\u2264i\u2264L.length\uff09\uff0c\u82e5\u4e0d\u5408\u7406\uff0c\u5219\u8fd4\u56deERROR\u3002<\/p>\n\n\n\n<p>\u2461\u82e5 i \u503c\u5408\u7406\uff0c\u5219\u5c06\u7b2c i \u4e2a\u6570\u636e\u5143\u7d20L.length[i-1]\u8d4b\u7ed9\u53c2\u6570 e \uff0c\u901a\u8fc7e\u8fd4\u56de\u7b2c i \u4e2a\u6570\u636e\u5143\u7d20\u7684\u4f20\u503c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int GetElem(SqList L, int i, ElemType&amp; e) {\nif (i&lt;1 || i&gt;L.length) {\nreturn ERROR;\n}\ne = L.elem&#91;i - 1];\nreturn OK;\n}<\/code><\/pre>\n\n\n\n<p>\u987a\u5e8f\u8868\u7684\u53d6\u503c\u7b97\u6cd5\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(1)\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u7684\u67e5\u627e<\/h3>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u4ece\u7b2c\u4e00\u4e2a\u5143\u7d20\u8d77\uff0c\u4f9d\u6b21\u5c06\u5176\u503c\u548ce\u76f8\u6bd4\u8f83\uff0c\u82e5\u627e\u5230\u503c\u4e0ee\u76f8\u7b49\u7684\u5143\u7d20L.elem[i]\uff0c\u5219\u67e5\u627e\u6210\u529f\uff0c\u8fd4\u56de\u8be5\u5143\u7d20\u7684\u5e8f\u53f7i+1\u3002<\/p>\n\n\n\n<p>\u2461\u82e5\u67e5\u627e\u6574\u4e2a\u987a\u5e8f\u8868\u90fd\u6ca1\u6709\u627e\u5230\uff0c\u5219\u67e5\u627e\u5931\u8d25\uff0c\u8fd4\u56de0\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int LocateElem(SqList L, ElemType e){\n    for(int i=0;i&lt;L.length;i++){\n        if(e==L.elem&#91;i])\n            return i+1;           \/\/\u627e\u5230\u8fd4\u56de\u4e0b\u6807\n    }\n    return 0;    \/\/\u6ca1\u627e\u5230\u8fd4\u56de0\n}<\/code><\/pre>\n\n\n\n<p>\u5f53\u5728\u987a\u5e8f\u8868\u4e2d\u67e5\u627e\u4e00\u4e2a\u6570\u636e\u5143\u7d20\u65f6\uff0c \u5176\u65f6\u95f4\u4e3b\u8981\u8017\u8d39\u5728\u6570\u636e\u7684\u6bd4\u8f83\u4e0a\uff0c \u800c\u6bd4\u8f83\u7684\u6b21\u6570\u53d6\u4e8e\u88ab\u67e5\u5143\u7d20\u5728\u7ebf\u6027\u8868\u4e2d\u7684\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<p>\u5728\u67e5\u627e\u65f6\uff0c \u4e3a\u786e\u5b9a\u5143\u7d20\u5728\u987a\u5e8f\u8868\u4e2d\u7684\u4f4d\u7f6e\uff0c \u9700\u548c\u7ed9\u5b9a\u503c\u8fdb\u884c\u6bd4\u8f83\u7684\u6570\u636e\u5143\u7d20\u4e2a\u6570\u7684\u671f\u671b\u79f0\u4e3a\u67e5\u627e\u7b97\u6cd5\u5728\u67e5\u627e\u6210\u529f\u65f6\u7684\u5e73\u5747\u67e5\u627e\u957f\u5ea6 ( Average Search Length, ASL)\u3002<\/p>\n\n\n\n<p>\u5047\u8bbepi ,(pi=1\/n\uff09\u662f\u67e5\u627e\u7684\u5143\u7d20\u5728\u7b2ci (1&lt;=i&lt;=L.length\uff09\u4e2a\u4f4d\u7f6e\u4e0a\u7684\u6982\u7387\uff0c\u5219\u5728\u957f\u5ea6\u4e3an\u7684\u7ebf\u6027\u8868\u4e2d\u67e5\u627e\u503c\u4e3ae\u7684\u5143\u7d20\u6240\u9700\u6bd4\u8f83\u7684\u5e73\u5747\u6b21\u6570\u4e3a\uff08n+1\uff09\/2\uff0c\u56e0\u6b64\uff0c\u7ebf\u6027\u8868\u6309\u503c\u67e5\u627e\u7b97\u6cd5\u7684\u5e73\u5747\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(n)\u3002<\/p>\n\n\n\n<p><strong>\u6700\u597d\u60c5\u51b5\uff1a<\/strong>\u67e5\u627e\u7684\u5143\u7d20\u5c31\u5728\u8868\u5934\uff0c\u4ec5\u9700\u6bd4\u8f83\u4e00\u6b21\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(1)\u3002<br><strong>\u6700\u574f\u60c5\u51b5\uff1a<\/strong>\u67e5\u627e\u7684\u5143\u7d20\u5728\u8868\u5c3e\uff08\u6216\u4e0d\u5b58\u5728\uff09\u65f6\uff0c\u9700\u8981\u6bd4\u8f83n\u6b21\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(n)\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u7684\u63d2\u5165<\/h3>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u5224\u65ad\u63d2\u5165\u4f4d\u7f6ei\u662f\u5426\u5408\u6cd5\uff08i\u503c\u5f97\u5408\u6cd5\u8303\u56f4\u4f7f1\u2264i\u2264n+1\uff09\uff0c\u82e5\u4e0d\u5408\u6cd5\u8fd4\u56deERROR\u3002<\/p>\n\n\n\n<p>\u2461\u5224\u65ad\u987a\u5e8f\u8868\u5f97\u5b58\u50a8\u7a7a\u95f4\u662f\u5426\u5df2\u6ee1\uff0c\u82e5\u6ee1\u5219\u8fd4\u56deERROR\u3002<\/p>\n\n\n\n<p>\u2462\u5c06\u7b2cn\u4e2a\u81f3\u7b2ci\u4e2a\u4f4d\u7f6e\u7684\u5143\u7d20\u4f9d\u6b21\u5411\u540e\u79fb\u52a8\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u7a7a\u51fa\u7b2ci\u4e2a\u4f4d\u7f6e\uff08i=n+1\u65f6\u65e0\u987b\u79fb\u52a8\uff09\u3002<\/p>\n\n\n\n<p>\u2463\u5c06\u8981\u63d2\u5165\u7684\u65b0\u5143\u7d20e\u653e\u5165\u7b2ci\u4e2a\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<p>\u2464\u8868\u957f\u52a01\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> int InsertElem(SqList &amp;L,int pos,ElemType &amp;e){\n\tif(pos&lt;1||pos&gt;L.length+1){\n\t\treturn ERROR;\n\t}\n\tif(L.length&gt;MAXSIZE){\n\t\treturn ERROR;\n\t}\n\tfor(i=L.length;i&gt;=pos;i--){\n\t\tL.elem&#91;i]=L.elem&#91;i-1];\n\t}\n\tL.elem&#91;pos-1]=e;\n\tL.length++;\n\treturn OK;\n}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u89e3\u91ca\u4e00\u4e0b\u4e3a\u4ec0\u4e48\u8981\u5c06\u5143\u7d20\u4f9d\u6b21\u5411\u540e\u79fb\u52a8\u4e00\u4e2a\u4f4d\u7f6e\u4e4b\u540e\u518d\u63d2\u5165\u5143\u7d20\u3002<\/p>\n\n\n\n<p>\u5728\u987a\u5e8f\u8868\u4e2d\u63d2\u5165\u4e00\u4e2a\u65b0\u5143\u7d20\u65f6\uff0c\u9700\u8981\u79fb\u52a8\u5143\u7d20\u7684\u539f\u56e0\u662f\u4e3a\u4e86\u7ed9\u65b0\u5143\u7d20\u817e\u51fa\u7a7a\u95f4\u3002\u8fd9\u662f\u56e0\u4e3a\u987a\u5e8f\u8868\u662f\u57fa\u4e8e\u6570\u7ec4\u5b9e\u73b0\u7684\uff0c\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u662f\u8fde\u7eed\u5b58\u50a8\u7684\u3002\u5982\u679c\u8981\u63d2\u5165\u7684\u65b0\u5143\u7d20\u4e0d\u662f\u5728\u6570\u7ec4\u7684\u672b\u5c3e\uff0c\u90a3\u4e48\u63d2\u5165\u64cd\u4f5c\u4f1a\u7834\u574f\u5143\u7d20\u7684\u8fde\u7eed\u6027\uff0c\u56e0\u6b64\u9700\u8981\u5c06\u63d2\u5165\u70b9\u4e4b\u540e\u7684\u5143\u7d20\u5411\u540e\u79fb\u52a8\uff0c\u4ee5\u4fdd\u6301\u6570\u7ec4\u4e2d\u5143\u7d20\u7684\u8fde\u7eed\u6027\u3002<\/p>\n\n\n\n<p>\u7b80\u5355\u7684\u89e3\u91ca\u5c31\u662f\u5982\u679c\u76f4\u63a5\u63d2\u5165\u5c31\u4f1a\u628a\u539f\u6765\u4f4d\u7f6e\u7684\u5143\u7d20\u7ed9\u8986\u76d6\u4e86\u3002\u5e76\u4e14\u79fb\u52a8\u5143\u7d20\u7684\u65f6\u5019\u8981\u4ece\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u5f00\u59cb\u79fb\u52a8\uff0c\u5426\u5219\u5143\u7d20\u4e5f\u4f1a\u88ab\u8986\u76d6\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u653e\u4e00\u4e2a\u56fe\u6765\u76f4\u89c2\u7684\u89e3\u91ca\u4e00\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/s21.ax1x.com\/2024\/09\/15\/pAuNVLn.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u6700\u597d\u60c5\u51b5:\u5728\u8868\u5c3e\u63d2\u5165(\u5373 i= n+1)\uff0c\u5143\u7d20\u540e\u79fb\u8bed\u53e5\u5c06\u4e0d\u6267\u884c\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(1) \u3002<\/p>\n\n\n\n<p>\u6700\u574f\u60c5\u51b5:\u5728\u8868\u5934\u63d2\u5165\uff08\u5373i= 1)\uff0c\u5143\u7d20\u540e\u79fb\u8bed\u53e5\u5c06\u6267\u884cn\u6b21\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(n)\u3002<br>\u5e73\u5747\u60c5\u51b5:\u5047\u8bbepi(pi = 1\/(n1+ 1)\uff09\u662f\u5728\u7b2c\u4e2a\u4f4d\u7f6e\u4e0a\u63d2\u5165\u4e00\u4e2a\u7ed3\u70b9\u7684\u6982\u7387\uff0c\u5219\u5728\u957f\u5ea6\u4e3an\u7684\u7ebf\u6027\u8868\u4e2d\u63d2\u5165\u4e00\u4e2a\u7ed3\u70b9\u65f6\uff0c\u6240\u9700\u79fb\u52a8\u7ed3\u70b9\u7684\u5e73\u5747\u6b21\u6570\u4e3an\/2\u3002\u56e0\u6b64\uff0c\u7ebf\u6027\u8868\u63d2\u5165\u7b97\u6cd5\u7684\u5e73\u5747\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(n)\u3002<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u7684\u5220\u9664<\/h3>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u5224\u65ad\u5220\u9664\u4f4d\u7f6e i \u662f\u5426\u5408\u6cd5\uff08\u5408\u6cd5\u503c\u4e3a 1\u2264i\u2264n\uff09\uff0c\u82e5\u4e0d\u5408\u6cd5\u5219\u8fd4\u56deERROR\u3002<\/p>\n\n\n\n<p>\u2461\u5c06\u7b2ci+1\u4e2a\u81f3\u7b2cn\u4e2a\u5143\u7d20\u4f9d\u6b21\u5411\u524d\u79fb\u52a8\u4e00\u4e2a\u4f4d\u7f6e\uff08i=n\u65f6\u65e0\u987b\u79fb\u52a8\uff09\u3002<\/p>\n\n\n\n<p>\u2462\u8868\u957f\u51cf1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bool ListDelete(SqList &amp;L,int i){\n    if(i&lt;1||i&gt;L.length)               \/\/\u5224\u65adi\u662f\u5426\u5728\u5408\u6cd5\u8303\u56f4\n        return ERROR;\n    for(int j=i;j&lt;=L.length-1;j++)       \/\/\u4ece\u7b2ci\u4e2a\u4f4d\u7f6e\u5f00\u59cb\u4ece\u540e\u5f80\u524d\u79fb\u52a8\n        L.elem&#91;j-1]=L,elem&#91;j];\n    L.length--;                       \/\/\u7ebf\u6027\u8868\u957f\u5ea6\u51cf1\n    rerurn OK;\n}<\/code><\/pre>\n\n\n\n<p>\u8981\u5220\u9664\u8868\u4e2d\u4e0b\u6807\u4e3ap\u7684\u5143\u7d20\uff0c\u53ea\u9700\u5c06\u5176\u540e\u8fb9\u7684\u5143\u7d20\u9010\u4e2a\u5f80\u524d\u79fb\u52a8\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u5c06p\u4f4d\u7f6e\u4e0a\u7684\u5143\u7d20\u8986\u76d6 \u6389\uff0c\u5c31\u8fbe\u5230\u4e86\u5220\u9664\u7684\u76ee\u7684\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/s21.ax1x.com\/2024\/09\/15\/pAuNsOA.png\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u7684\u6e05\u7a7a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>void ClearList(SqList &amp;L) {\n    free(L.elem);\n    L.elem = NULL; \/\/ \u6216\u8005\u4f7f\u7528nullptr\n    L.length = 0;\n    L.capacity = 0;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u7684\u904d\u5386<\/h3>\n\n\n\n<p>\u904d\u5386\u987a\u5e8f\u8868\u4e2d\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\uff0c\u901a\u5e38\u7528\u4e8e\u6253\u5370\u6216\u5176\u4ed6\u64cd\u4f5c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void Traverse(SqList &amp;L) {\n    for (int i = 0; i &lt; L.length; ++i) {\n        printf(\"%d \", L.elem&#91;i]);\n    }\n    printf(\"\\n\");\n}<\/code><\/pre>\n\n\n\n<p>\u65f6\u95f4\u590d\u6742\u5ea6\uff1ao(n\uff09<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u8bbf\u95ee\u5143\u7d20<\/h3>\n\n\n\n<p>\u8bbf\u95ee\u987a\u5e8f\u8868\u4e2d\u7684\u6307\u5b9a\u4f4d\u7f6e\u7684\u5143\u7d20\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ElemType get(SqList &amp;L, int index) {\n    if (index &gt;= 0 &amp;&amp; index &lt; L.length) {\n        return L.elem&#91;index];\n    }\n    \/\/ \u8fd4\u56de\u9519\u8bef\u6807\u5fd7\u6216\u629b\u51fa\u5f02\u5e38\n    return ERROR;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u8d4b\u503c<\/h3>\n\n\n\n<p>\u4e3a\u987a\u5e8f\u8868\u52a0\u5165\u5143\u7d20<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void Assign(SqList&amp; L) {\n\tint i, N;\n\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u987a\u5e8f\u8868\u4e2d\u5143\u7d20\u7684\u4e2a\u6570\" &lt;&lt; endl;\n\tcin &gt;&gt; N;\n\tcout &lt;&lt; \"\u8bf7\u8f93\u5165\u5143\u7d20\" &lt;&lt; endl;\n\tfor (i = 0; i &lt; N; i++)\n\t{\n\t\tcin &gt;&gt; L.elem&#91;i];\n\t\tL.length++;\n\t}\n}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u6211\u4f7f\u7528\u4e86C++\u53bb\u5199\uff0c\u5176\u4e2d\u7684cout\u76f8\u5f53\u4e8eprintf\uff0cendl\u76f8\u5f53\u4e8e\\n\uff0ccin\u76f8\u5f53\u4e8escanf\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u987a\u5e8f\u8868\u7684\u6269\u5bb9<\/h3>\n\n\n\n<p>\u5f53\u987a\u5e8f\u8868\u5df2\u6ee1\u65f6\uff0c\u9700\u8981\u6269\u5bb9\u4ee5\u5bb9\u7eb3\u66f4\u591a\u5143\u7d20\u3002\u8fd9\u901a\u5e38\u6d89\u53ca\u5230\u91cd\u65b0\u5206\u914d\u66f4\u5927\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u5e76\u5c06\u539f\u6709\u6570\u636e\u590d\u5236\u8fc7\u53bb\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bool resize(SqList &amp;L, int newSize) {\n    ElemType *newData = (ElemType*)realloc(L.elem, sizeof(ElemType) * newSize);\n    if (newData != NULL) {\n        L.elem = newData;\n        L.capacity = newSize;\n        return OK;\n    }\n    return ERROR;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e24\u4e2a\u975e\u9012\u51cf\u6709\u5e8f\u987a\u5e8f\u8868\u7684\u5f52\u5e76<\/h3>\n\n\n\n<p>\u7b97\u6cd5\u6b65\u9aa4<\/p>\n\n\n\n<p>\u2460\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u987a\u5e8f\u8868\uff0c\u5176\u957f\u5ea6length\u4e3a\u8981\u5408\u5e76\u7684\u987a\u5e8f\u8868\u957f\u5ea6\u7684\u603b\u957f\u3002<\/p>\n\n\n\n<p>\u2461\u68c0\u67e5\u5185\u5b58\u662f\u5426\u5206\u914d\u5931\u8d25\u3002<\/p>\n\n\n\n<p>\u2462\u521d\u59cb\u5316\u4e09\u4e2a\u7d22\u5f15\u53d8\u91cfi\u3001j\u3001k\uff0c\u5206\u522b\u7528\u6765\u8bb0\u5f55\u5f53\u524dL1\u3001L2\u4ee5\u53caL3\u4e2d\u7684\u5f53\u524d\u4f4d\u7f6e\u3002\u521d\u59cb\u503c\u90fd\u8bbe\u4e3a0.<\/p>\n\n\n\n<p>\u2463<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u4e00\u4e2a\u5faa\u73af\u540c\u65f6\u904d\u5386L1\u548cL2\uff0c\u76f4\u5230\u5176\u4e2d\u4e00\u4e2a\u88ab\u5b8c\u5168\u904d\u5386\u3002<\/li>\n\n\n\n<li>\u6bcf\u6b21\u8fed\u4ee3\u4e2d\u6bd4\u8f83L1.elem[ i ]\u548cL2.elem[ j ]\u7684\u503c\u3002<\/li>\n\n\n\n<li>\u5982\u679cL1.elem[ i ]\u5c0f\u4e8e\u7b49\u4e8eL2.elem[ j ]\u7684\u503c\uff0c\u5219\u5c06L1.elem[ i ]\u7684\u503c\u8d4b\u7ed9L3.elem[ k ],\u7136\u540e\u589e\u52a0i\u548ck \u3002<\/li>\n\n\n\n<li>\u5426\u5219\u5c06L2.elem[ j ]\u7684\u503c\u8d4b\u7ed9L3.elem[ k ]\uff0c\u7136\u540e\u589e\u52a0j\u548ck\u7684\u503c\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u2464<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c<code>L1<\/code>\u4e2d\u6709\u5269\u4f59\u5143\u7d20\u672a\u88ab\u590d\u5236\uff08\u5373<code>i &lt; L1.length<\/code>\uff09\uff0c\u7ee7\u7eed\u5c06\u8fd9\u4e9b\u5143\u7d20\u4f9d\u6b21\u590d\u5236\u5230<code>L3<\/code>\u4e2d\u3002<\/li>\n\n\n\n<li>\u5982\u679c<code>L2<\/code>\u4e2d\u6709\u5269\u4f59\u5143\u7d20\u672a\u88ab\u590d\u5236\uff08\u5373<code>j &lt; L2.length<\/code>\uff09\uff0c\u540c\u6837\u5c06\u8fd9\u4e9b\u5143\u7d20\u4f9d\u6b21\u590d\u5236\u5230<code>L3<\/code>\u4e2d<\/li>\n<\/ul>\n\n\n\n<p>\u2465\u66f4\u65b0<code>L3<\/code>\u7684\u957f\u5ea6\u4e3a<code>k<\/code>\uff0c\u5373\u5df2\u590d\u5236\u5230<code>L3<\/code>\u4e2d\u7684\u5143\u7d20\u603b\u6570\u3002<\/p>\n\n\n\n<p>\u2466\u901a\u8fc7\u4e00\u4e2a\u5faa\u73af\u6253\u5370\u51fa<code>L3<\/code>\u4e2d\u7684\u6240\u6709\u5143\u7d20\uff0c\u6bcf\u4e2a\u5143\u7d20\u540e\u6362\u884c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int Merge(SqList &amp;L1,SqList &amp;L2){\n\tSqList L3;\n\tL3.elem=new ElemType&#91;L1.length+L2.length];\n\tif(L3.elem==NULL){\n\t\treturn ERROR;\n\t}\n\tint i=0,j=0,k=0;\n\twhile(i&lt;L1.length&amp;&amp;j&lt;L2.length){\n\t\tif(L1.elem&#91;i]&lt;=L2.elem&#91;j]) {\n\t\t\tL3.elem&#91;k++]=L1.elem&#91;i++];\n\t\t}\n\t\telse{\n\t\t\tL3.elem&#91;k++]=L2.elem&#91;j++];\n\t\t}\n\t}\n\t\/\/\u590d\u5236L1\u4e2d\u5269\u4f59\u7684\u5143\u7d20\n\twhile(i&lt;L1.length){\n\t\tL3.elem&#91;k++]=L1.elem&#91;i++];\n\t} \n\t\/\/\u590d\u5236L2\u4e2d\u5269\u4f59\u7684\u5143\u7d20\n\twhile(j&lt;L2.length){\n\t\tL3.elem&#91;k++] = L2.elem&#91;j++];\n\t} \n\tL3.length = k;\n\tfor (i = 0; i &lt; L3.length; i++) {\n\t\tcout &lt;&lt; L3.elem&#91;i] &lt;&lt; endl;\n\t}\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5177\u4f53\u5b9e\u73b0<\/h2>\n\n\n\n<p>\u8fd9\u91cc\u9644\u4e0a\u4e00\u4e2a\u6211\u4e4b\u524d\u5199\u7684\u987a\u5e8f\u8868\u7684\u5b9e\u73b0\uff0c\u4f7f\u7528\u7684\u662f\u7ed3\u6784\u4f53\u6570\u636e\u7c7b\u578b\uff0c\u91cc\u9762\u6d89\u53ca\u987a\u5e8f\u8868\u7684\u904d\u5386\uff0c\u6279\u91cf\u6dfb\u52a0\u7b49\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;\n#include &lt;stdlib.h&gt;\nusing namespace std;\n#define OK 1\n#define ERROR 0\n#define MAX 100\n\/\/\u5b9a\u4e49\u56fe\u4e66\u7ed3\u6784\u4f53\ntypedef struct {\n\tchar no&#91;50];\n\tchar title&#91;50];\n\tfloat price;\n}Book;\n\/\/\u5b9a\u4e49\u987a\u5e8f\u8868\u7ed3\u6784\u4f53\ntypedef struct {\n\tBook* elem;\/\/\u52a8\u6001\u6570\u7ec4 \n\tint length;\/\/\u5f53\u524d\u56fe\u4e66\u6570\u91cf\n}SqList;\n\/\/\u51fd\u6570\u58f0\u660e\nint InitList(SqList&amp; L);\nint Insert(SqList&amp; L,int position,Book e);\nint BulkInsert(SqList&amp; L, Book books&#91;], int count);\nint Traverse(SqList L);\n\nint main() {\n\tSqList L;\n\tBook books&#91;] = { {\"1234\",\"\u5c0f\u7ea2\u4e66\",22.33},\n\t{\"2233\",\"\u5c0f\u9ed1\u4e66\",44.66},\n\t\t{\"3344\",\"\u5c0f\u84dd\u4e66\",55.77},\n\t\t{\"4455\",\"\u5c0f\u7d2b\u4e66\",66.77},\n\t\t{\"6677\",\"\u5c0f\u7eff\u4e66\",111.222}\n\t};\n\tint bookcount = sizeof(books)\/sizeof(Book);\n\t\/\/\u521d\u59cb\u5316\u987a\u5e8f\u8868\n\tif (!InitList(L)) {\n\t\tcout &lt;&lt; \"\u521d\u59cb\u5316\u5931\u8d25\" &lt;&lt; endl;\n\t\treturn 1;\n\t}\n\t\/\/\u6279\u91cf\u63d2\u5165\u56fe\u4e66\n\tif (BulkInsert(L, books, bookcount)!=OK) {\n\t\tcout &lt;&lt; \"\u63d2\u5165\u5931\u8d25\" &lt;&lt; endl;\n\t\treturn 1;\n\t}\n\t\/\/\u904d\u5386\u5e76\u663e\u793a\u56fe\u4e66\u4fe1\u606f\n\tTraverse(L);\n\treturn 0;\n}\nint InitList(SqList&amp; L) {\n\tL.elem = new Book&#91;100];\n\tif (L.elem == NULL) {\n\t\treturn ERROR;\n\t}\n\tL.length = 0;\n\treturn OK;\n}\nint Insert(SqList&amp; L, int pos, Book e) {\n\tif (pos&lt;1 || pos&gt;L.length + 1) {\n\t\treturn ERROR;\n\t}\n\tif (L.length &gt;= 100) {\n\t\treturn ERROR;\n\t}\n\tfor (int i = L.length; i &gt;= pos; i--) {\n\t\tL.elem&#91;i] = L.elem&#91;i - 1];\n\t}\n\tL.elem&#91;pos - 1] = e;\n\tL.length++;\n\treturn OK;\n}\n\/\/\u63d2\u5165\u6279\u91cf\u56fe\u4e66\nint BulkInsert(SqList&amp; L, Book books&#91;], int count) {\n\tfor (int i = 0; i &lt; count; i++) {\n\t\tif (Insert(L, L.length + 1, books&#91;i]) != OK) {\n\t\t\treturn ERROR;\n\t\t}\n\t}\n\treturn OK;\n}\n\/\/\u904d\u5386\u987a\u5e8f\u8868\nint Traverse(SqList L) {\n\tfor (int i = 0; i &lt; L.length; i++) {\n\t\tcout &lt;&lt; \"\u5e8f\u53f7:\" &lt;&lt; L.elem&#91;i].no &lt;&lt; endl;\n\t\tcout &lt;&lt; \"\u4e66\u540d:\" &lt;&lt; L.elem&#91;i].title &lt;&lt; endl;\n\t\tcout &lt;&lt; \"\u4ef7\u683c:\" &lt;&lt; L.elem&#91;i].price &lt;&lt; endl;\n\t}\n\treturn OK;\n}\nint GetElem(SqList L, int i, Book&amp; e) {\n\tif (i&lt;1 || i&gt;L.length) {\n\t\treturn ERROR;\n\t}\n\te = L.elem&#91;i - 1];\n\treturn OK;\n}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u6211\u4f7f\u7528\u4e86C++\u53bb\u5199\uff0c\u5176\u4e2d\u7684cout\u76f8\u5f53\u4e8eprintf\uff0cendl\u76f8\u5f53\u4e8e\\n\uff0ccin\u76f8\u5f53\u4e8escanf\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u9762\u7528\u5230\u7684\u51fd\u6570\u9664\u4e86\u6279\u91cf\u63d2\u5165\u4ee5\u5916\uff0c\u4e0a\u6587\u90fd\u8bb2\u5230\u8fc7\uff0c\u5176\u4e2d int bookcount = sizeof(books)\/sizeof(Book);\u7684\u89e3\u91ca\u662f\uff1a<\/p>\n\n\n\n<p>\u5728 C\/C++ \u4e2d\uff0csizeof \u662f\u4e00\u4e2a\u8fd0\u7b97\u7b26\uff0c\u7528\u6765\u83b7\u53d6\u6570\u636e\u7c7b\u578b\u6216\u8005\u5bf9\u8c61\u7684\u5927\u5c0f\uff0c\u5728\u5b57\u8282\u5355\u4f4d\u4e0b\u3002\u5982\u679c\u4f60\u6709\u4e00\u4e2a\u6570\u7ec4 books\uff0c\u5e76\u4e14 Book \u662f\u5b9a\u4e49\u597d\u7684\u7ed3\u6784\u4f53\u7c7b\u578b\uff0c\u90a3\u4e48\u8868\u8fbe\u5f0f sizeof(books)\/sizeof(Book) \u6216\u8005sizeof(books)\/sizeof(Book) \u7528\u6765\u8ba1\u7b97\u6570\u7ec4 books \u4e2d Book \u7c7b\u578b\u5143\u7d20\u7684\u6570\u91cf\u3002<\/p>\n\n\n\n<p>\u518d\u6765\u4e00\u4e2a\u4f8b\u5b50\uff0c\u8fd9\u4e2a\u4f8b\u5b50\u76f8\u5bf9\u6765\u8bf4\u66f4\u52a0\u5168\u9762\u4e00\u70b9\uff1a<\/p>\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\ntypedef struct {\n    ElemType* elem;\n    int length;\n} SqList;\n\n\/\/ \u521d\u59cb\u5316\u987a\u5e8f\u8868\nStatus InitList(SqList&amp; L) {\n    L.elem = new ElemType&#91;MAXSIZE];\n    if (!L.elem) {\n        return OVERFLOW;\n    }\n    L.length = 0;\n    return OK;\n}\n\n\/\/ \u8d4b\u503c\u64cd\u4f5c\nvoid Assign(SqList&amp; L) {\n    int N;\n    cout &lt;&lt; \"\u8bf7\u8f93\u5165\u987a\u5e8f\u8868\u4e2d\u5143\u7d20\u7684\u4e2a\u6570: \";\n    cin &gt;&gt; N;\n    cout &lt;&lt; \"\u8bf7\u8f93\u5165\u5143\u7d20: \" &lt;&lt; endl;\n    for (int i = 0; i &lt; N; i++) {\n        cin &gt;&gt; L.elem&#91;i];\n        L.length++;\n    }\n}\n\n\/\/ \u53d6\u503c\u64cd\u4f5c\nStatus GetElem(const SqList L, int index, ElemType&amp; e) {\n    if (index &lt; 1 || index &gt; L.length) {\n        return ERROR;\n    }\n    e = L.elem&#91;index - 1];\n    return OK;\n}\n\n\/\/ \u67e5\u627e\u64cd\u4f5c\nint LocateElem(const SqList L, ElemType e) {\n    for (int i = 0; i &lt; L.length; i++) {\n        if (e == L.elem&#91;i]) {\n            return i + 1; \/\/ \u627e\u5230\u8fd4\u56de\u4e0b\u6807\n        }\n    }\n    return 0; \/\/ \u6ca1\u6709\u627e\u5230\u8fd4\u56de0\n}\n\n\/\/ \u63d2\u5165\u64cd\u4f5c\nStatus InsertElem(SqList&amp; L, int pos, ElemType e) {\n    if (pos &lt; 1 || pos &gt; L.length + 1) {\n        return ERROR;\n    }\n    if (L.length &gt;= MAXSIZE) {\n        return ERROR;\n    }\n    for (int i = L.length; i &gt;= pos; i--) {\n        L.elem&#91;i] = L.elem&#91;i - 1];\n    }\n    L.elem&#91;pos - 1] = e;\n    L.length++;\n    return OK;\n}\n\n\/\/ \u5220\u9664\u64cd\u4f5c\nStatus DeletElem(SqList&amp; L, int index) {\n    if (index &lt; 1 || index &gt; L.length) {\n        return ERROR;\n    }\n    for (int j = index; j &lt; L.length; j++) {\n        L.elem&#91;j - 1] = L.elem&#91;j];\n    }\n    L.length--;\n    return OK;\n}\n\n\/\/ \u904d\u5386\u64cd\u4f5c\nvoid Traverse(const SqList L) {\n    for (int i = 0; i &lt; L.length; i++) {\n        cout &lt;&lt; L.elem&#91;i] &lt;&lt; endl;\n    }\n}\n\n\/\/ \u5f52\u5e76\u4e24\u4e2a\u975e\u9012\u51cf\u6709\u5e8f\u987a\u5e8f\u8868\nStatus Merge(SqList&amp; L1, SqList&amp; L2) {\n    SqList L3;\n    L3.elem = new ElemType&#91;L1.length + L2.length];\n    if (!L3.elem) {\n        return ERROR;\n    }\n    int i = 0, j = 0, k = 0;\n    while (i &lt; L1.length &amp;&amp; j &lt; L2.length) {\n        if (L1.elem&#91;i] &lt;= L2.elem&#91;j]) {\n            L3.elem&#91;k++] = L1.elem&#91;i++];\n        }\n        else {\n            L3.elem&#91;k++] = L2.elem&#91;j++];\n        }\n    }\n    \/\/ \u590d\u5236L1\u4e2d\u5269\u4f59\u7684\u5143\u7d20\n    while (i &lt; L1.length) {\n        L3.elem&#91;k++] = L1.elem&#91;i++];\n    }\n    \/\/ \u590d\u5236L2\u4e2d\u5269\u4f59\u7684\u5143\u7d20\n    while (j &lt; L2.length) {\n        L3.elem&#91;k++] = L2.elem&#91;j++];\n    }\n    L3.length = k;\n    for (i = 0; i &lt; L3.length; i++) {\n        cout &lt;&lt; L3.elem&#91;i] &lt;&lt; endl;\n    }\n    delete&#91;] L3.elem; \/\/ \u91ca\u653e\u5185\u5b58\n    return OK;\n}\n\nint main() {\n    SqList L1, L2, L3;\n    Status status;\n    int choice, pos, index, value;\n    ElemType e;\n    bool isInitList = false;\n\n    while (true) {\n        cout &lt;&lt; \"\u8bf7\u9009\u62e9\u64cd\u4f5c:\\n\"\n            &lt;&lt; \"1. \u521d\u59cb\u5316\u987a\u5e8f\u8868\\n\"\n            &lt;&lt; \"2. \u8d4b\u503c\\n\"\n            &lt;&lt; \"3. \u53d6\u503c\\n\"\n            &lt;&lt; \"4. \u67e5\u627e\\n\"\n            &lt;&lt; \"5. \u63d2\u5165\\n\"\n            &lt;&lt; \"6. \u5220\u9664\\n\"\n            &lt;&lt; \"7. \u904d\u5386\\n\"\n            &lt;&lt; \"8. \u5f52\u5e76\\n\"\n            &lt;&lt; \"9. \u9000\u51fa\\n\";\n        cin &gt;&gt; choice;\n        if (!isInitList &amp;&amp; choice != 1 &amp;&amp; choice != 9) {\n            cout &lt;&lt; \"\u8bf7\u5148\u521d\u59cb\u5316\u987a\u5e8f\u8868!\" &lt;&lt; endl;\n            continue;\n        }\n\n        switch (choice) {\n        case 1:\n            status = InitList(L1);\n            if (status == OK) {\n                cout &lt;&lt; \"\u521d\u59cb\u5316\u987a\u5e8f\u8868\u6210\u529f!\" &lt;&lt; endl;\n                isInitList = true;\n            }\n            else {\n                cout &lt;&lt; \"\u521d\u59cb\u5316\u987a\u5e8f\u8868\u5931\u8d25!\" &lt;&lt; endl;\n            }\n            break;\n        case 2:\n            Assign(L1);\n            break;\n        case 3:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u7d22\u5f15: \";\n            cin &gt;&gt; index;\n            status = GetElem(L1, index, e);\n            if (status == OK) {\n                cout &lt;&lt; \"\u5143\u7d20\u4e3a: \" &lt;&lt; e &lt;&lt; endl;\n            }\n            else {\n                cout &lt;&lt; \"\u7d22\u5f15\u9519\u8bef!\" &lt;&lt; endl;\n            }\n            break;\n        case 4:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u5143\u7d20: \";\n            cin &gt;&gt; e;\n            index = LocateElem(L1, e);\n            if (index != 0) {\n                cout &lt;&lt; \"\u5143\u7d20\u4f4d\u7f6e: \" &lt;&lt; index &lt;&lt; endl;\n            }\n            else {\n                cout &lt;&lt; \"\u672a\u627e\u5230\u8be5\u5143\u7d20!\" &lt;&lt; endl;\n            }\n            break;\n        case 5:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u63d2\u5165\u4f4d\u7f6e\u548c\u5143\u7d20: \";\n            cin &gt;&gt; pos &gt;&gt; value;\n            status = InsertElem(L1, pos, value);\n            if (status == OK) {\n                cout &lt;&lt; \"\u63d2\u5165\u6210\u529f!\" &lt;&lt; endl;\n            }\n            else {\n                cout &lt;&lt; \"\u63d2\u5165\u5931\u8d25!\" &lt;&lt; endl;\n            }\n            break;\n        case 6:\n            cout &lt;&lt; \"\u8bf7\u8f93\u5165\u5220\u9664\u4f4d\u7f6e: \";\n            cin &gt;&gt; index;\n            status = DeletElem(L1, index);\n            if (status == OK) {\n                cout &lt;&lt; \"\u5220\u9664\u6210\u529f!\" &lt;&lt; endl;\n            }\n            else {\n                cout &lt;&lt; \"\u5220\u9664\u5931\u8d25!\" &lt;&lt; endl;\n            }\n            break;\n        case 7:\n            cout &lt;&lt; \"\u904d\u5386\u987a\u5e8f\u8868:\" &lt;&lt; endl;\n            Traverse(L1);\n            break;\n        case 8:\n            status = InitList(L2); \/\/ \u5148\u521d\u59cb\u5316\u7b2c\u4e8c\u4e2a\u5217\u8868\n            if (status == OK) {\n                Assign(L2); \/\/ \u7136\u540e\u8d4b\u503c\n                status = Merge(L1, L2);\n                if (status == OK) {\n                    cout &lt;&lt; \"\u5408\u5e76\u5b8c\u6210!\" &lt;&lt; endl;\n                }\n                else {\n                    cout &lt;&lt; \"\u5408\u5e76\u5931\u8d25!\" &lt;&lt; endl;\n                }\n            }\n            break;\n        case 9:\n            cout &lt;&lt; \"\u9000\u51fa\u7a0b\u5e8f!\" &lt;&lt; endl;\n            return 0;\n        default:\n            cout &lt;&lt; \"\u65e0\u6548\u7684\u9009\u62e9\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165!\" &lt;&lt; endl;\n            break;\n        }\n    }\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u4f8b\u5b50\u611f\u89c9\u6ca1\u4ec0\u4e48\u53ef\u4ee5\u89e3\u91ca\u7684\u4e86\uff0c\u5c31\u662f\u4e0a\u9762\u662f\u4ecb\u7ecd\u7684\u987a\u5e8f\u8868\u64cd\u4f5c\u7684\u96c6\u5408\u4f53\uff0c\u91cc\u9762\u589e\u52a0\u4e86\u4e00\u4e2a\u7528\u6765\u5224\u65ad\u987a\u5e8f\u8868\u662f\u5426\u521d\u59cb\u5316\u7684isInitList\uff0c\u5982\u679c\u6ca1\u6709\u521d\u59cb\u5316\u5c31\u5c1d\u8bd5\u8fdb\u884c\u8d4b\u503c\u3001\u53d6\u503c\u3001\u67e5\u627e\u7b49\u64cd\u4f5c\uff0c\u90a3\u4e48\u7a0b\u5e8f\u4f1a\u8bbf\u95ee\u5230\u672a\u5b9a\u4e49\u7684\u6307\u9488\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u7a0b\u5e8f\u5d29\u6e83\u6216\u4ea7\u751f\u4e0d\u53ef\u9884\u6d4b\u7684\u884c\u4e3a\u3002\u53ea\u6709\u5f53\u5217\u8868\u88ab\u521d\u59cb\u5316\u540e\uff0c\u624d\u5141\u8bb8\u7528\u6237\u9009\u62e9\u5176\u4ed6\u64cd\u4f5c\u3002\u8fd9\u6837\u589e\u52a0\u4e86\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\uff0c\u4f46\u662f\u8fd9\u4e2a\u7a0b\u5e8f\u76ee\u524d\u8fd8\u662f\u6ca1\u6709\u975e\u5e38\u4e25\u8c28\uff0c\u53ea\u662f\u5177\u5907\u4e86\u6700\u57fa\u7840\u7684\u529f\u80fd\u548c\u4e00\u4e9b\u7b80\u5355\u7684\u9519\u8bef\u5224\u65ad\uff0c\u7528\u6765\u5f53\u4f5c\u53c2\u8003\uff0c\u5176\u5065\u58ee\u6027\u8fd8\u53ef\u4ee5\u7ee7\u7eed\u589e\u52a0\uff0c\u8fd9\u91cc\u4e3a\u4e86\u4e0d\u4f7f\u6587\u7ae0\u8fc7\u4e8e\u5197\u957f\uff0c\u5c31\u4e0d\u518d\u8d58\u8ff0\uff0c\u60f3\u77e5\u9053\u66f4\u591a\u7684\u53ef\u4ee5\u53bb\u767e\u5ea6\u6216\u8005\u8be2\u95eeAI\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5199\u5728\u6700\u540e<\/h2>\n\n\n\n<p>\u6709\u7684\u4eba\u53ef\u80fd\u4f1a\u5bf9\u4ec0\u4e48\u65f6\u5019\u4f7f\u7528&amp;\u800c\u611f\u5230\u7591\u95ee\uff0c\u8fd9\u91cc\u7b80\u5355\u8bf4\u4e00\u4e0b\uff0c\u53ea\u8981\u6d89\u53ca\u5230\u5730\u5740\u90fd\u8981\u52a0&amp;\u3002<\/p>\n\n\n\n<p>\u8fd9\u7bc7\u987a\u5e8f\u8868\u867d\u7136\u662f\u6570\u636e\u7ed3\u6784\u4e2d\u6700\u7b80\u5355\u7684\u90e8\u5206\uff0c\u4f46\u662f\u5199\u8fd9\u7bc7\u6587\u7ae0\u8fd8\u662f\u82b1\u4e86\u6211\u597d\u51e0\u4e2a\u5c0f\u65f6\uff0c\u4e2d\u95f4\u4e0d\u4ec5\u4ec5\u8981\u4ee5\u6211\u7684\u7406\u89e3\u53bb\u7f16\u5199\u6587\u7ae0\uff0c\u800c\u4e14\u8fd8\u8981\u67e5\u627e\u4e0d\u5c11\u7684\u8d44\u6599\u6765\u4f7f\u8fd9\u7bc7\u6587\u7ae0\u66f4\u52a0\u4e25\u8c28\uff0c\u66f4\u52a0\u8be6\u7ec6\u3002<\/p>\n\n\n\n<p>\u8fd9\u7bc7\u6587\u7ae0\u5148\u5199\u4e0e\u5b83\u7684\u524d\u7bc7\u7ebf\u6027\u8868\uff0c\u7b97\u662f\u7ee7MC\u8054\u673a\u6559\u7a0b\u4ee5\u5916\u76ee\u524d\u6211\u5199\u8fc7\uff0c\u4e5f\u662f\u6211\u82b1\u8d39\u65f6\u95f4\u6700\u957f\u7684\u4e00\u7bc7\u6587\u7ae0\u4e86\uff0c\u5728\u5199\u8fd9\u7bc7\u6587\u7ae0\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u8fd8\u4f1a\u60f3\u8fd9\u6837\u5199\u5bb9\u4e0d\u5bb9\u6613\u7406\u89e3\uff0c\u5728\u8fd9\u4e2a\u5730\u65b9\u4f1a\u4e0d\u4f1a\u4ea7\u751f\u7591\u95ee......\u5c3d\u7ba1\u662f\u8fd9\u6837\uff0c\u4f46\u8fd8\u662f\u611f\u89c9\u9057\u6f0f\u4e86\u4e0d\u5c11\u4e1c\u897f\uff0c\u5982\u679c\u5728\u9605\u8bfb\uff0c\u5b66\u4e60\u8fc7\u7a0b\u4e2d\u53d1\u73b0\u95ee\u9898\u6216\u8005\u4ea7\u751f\u7591\u95ee\uff0c\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u7559\u4e0b\u8ba8\u8bba\uff0c\u6211\u4f1a\u5c3d\u53ef\u80fd\u5730\u53bb\u89e3\u51b3\u7684\u3002<\/p>\n\n\n\n<p>\u8fd9\u7bc7\u6587\u7ae0\u76ee\u524d\u5df2\u7ecf\u6539\u8fc75\u6b21\u4e86\uff0c\u5176\u4e2d\u5305\u62ec\u589e\u52a0\u7f3a\u5c11\u7684\u793a\u4f8b\u4ee3\u7801\uff0c\u589e\u52a0\u987a\u5e8f\u8868\u7684\u5f52\u5e76\u64cd\u4f5c\uff0c\u4ee5\u53ca\u589e\u52a0\u4e86\u4e00\u4e2a\u65b0\u7684\u4f8b\u5b50\u3002<\/p>\n\n\n\n<p>\u7b2c\u516d\u6b21\u4fee\u6539\u589e\u52a0\u4e86\u5f52\u5e76\u64cd\u4f5c\u7684\u7b97\u6cd5\u6b65\u9aa4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u8fd9\u662fC\u8bed\u8a00\u6570\u636e\u7ed3\u6784\u4e2d\u6700\u7b80\u5355\u7684\u987a\u5e8f\u8868\uff0c\u9700\u8981\u6709\u6307\u9488\u548c\u7ed3\u6784\u4f53\u7684\u57fa\u7840\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4f1a\u5c3d\u53ef\u80fd\u4ee5\u6211\u7684\u7406\u89e3\u518d\u914d\u4e0a\u4e00\u4e9b\u8f83\u4e3a\u5b98\u65b9\u7684\u89e3\u91ca\u6765\u4f7f\u770b\u8fd9\u7bc7\u6587 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":131,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,17],"tags":[11,13,18],"class_list":["post-123","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","category-17","tag-c","tag-13","tag-18"],"_links":{"self":[{"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts\/123"}],"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=123"}],"version-history":[{"count":21,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts\/123\/revisions"}],"predecessor-version":[{"id":205,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts\/123\/revisions\/205"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/media\/131"}],"wp:attachment":[{"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/media?parent=123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/categories?post=123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/tags?post=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}