{"id":530,"date":"2024-11-15T19:08:37","date_gmt":"2024-11-15T11:08:37","guid":{"rendered":"http:\/\/8.138.167.183\/?p=530"},"modified":"2024-11-15T19:08:37","modified_gmt":"2024-11-15T11:08:37","slug":"%e5%b9%bf%e4%b9%89%e8%a1%a8%e4%b9%8b%e8%a1%a8%e5%a4%b4%e8%a1%a8%e5%b0%be%e8%a1%a8%e7%a4%ba%e6%b3%95","status":"publish","type":"post","link":"https:\/\/heqiwei.cn\/index.php\/2024\/11\/15\/%e5%b9%bf%e4%b9%89%e8%a1%a8%e4%b9%8b%e8%a1%a8%e5%a4%b4%e8%a1%a8%e5%b0%be%e8%a1%a8%e7%a4%ba%e6%b3%95\/","title":{"rendered":"\u5e7f\u4e49\u8868\u4e4b\u8868\u5934\u8868\u5c3e\u8868\u793a\u6cd5"},"content":{"rendered":"\n<p><strong>\u9898\u76ee\u8981\u6c42\u5982\u4e0b\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/heqiwei.cn\/wp-content\/uploads\/2024\/11\/\u5fae\u4fe1\u56fe\u7247_20241115190248-1024x88.jpg'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"88\" data-original=\"http:\/\/heqiwei.cn\/wp-content\/uploads\/2024\/11\/\u5fae\u4fe1\u56fe\u7247_20241115190248-1024x88.jpg\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-531\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<p><strong>\u8bb0\u5f55\u4e00\u4e0b\u6b64\u6b21\u5b66\u4e60\u8fc7\u7a0b\uff1a<\/strong><\/p>\n\n\n\n<p><strong>\u4ee3\u7801\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;stdio.h>\n#include&lt;stdlib.h>\n#include&lt;string.h>\ntypedef struct GNode\n{\n\tint Tag; \/\/ 0\u8868\u793a\u539f\u5b50\uff0c1\u8868\u793a\u5217\u8868\n\tunion\n\t{\n\t\tchar atom; \/\/ \u539f\u5b50\u503c\n\t\tstruct \/\/ \u6307\u9488\u57df\n\t\t{\n\t\t\tstruct GNode* hp, * tp; \/\/ hp\u8fde\u63a5\u5f53\u524d\u8868\u7684\u5b50\u8868\uff0ctp\u8fde\u63a5\u4e0b\u4e00\u4e2a\u5b50\u8868\n\t\t}ptr;\n\t};\n}*General_List, GNode;\n\nvoid SubString(char sub&#91;], char str&#91;], int start, int len) \/\/ \u5c06str\u4e2d\u90e8\u5206\u5185\u5bb9\u8d4b\u503c\u7ed9sub\u4e32\n{\n\tint i = 0;\n\tfor (; i &lt; len; ++i)\n\t\tsub&#91;i] = str&#91;start + i - 1];\n\tsub&#91;i] = '\\0'; \/\/ \u7ed3\u5c3e\u8865\u4e32\u7ed3\u675f\u7b26\n}\n\nvoid SeperateList(char* head, char* tail) \/\/ \u5c06\u8868tail\u5206\u79bb\u6210\u8868\u5934\u548c\u8868\u5c3e\n{\n\tint i = 0, cnt = 0, len = strlen(tail);\n\tfor (; i &lt; len; ++i)\n\t{\n\t\tif (tail&#91;i] == '(') cnt++;\n\t\tif (tail&#91;i] == ')') cnt--;\n\t\tif (!cnt &amp;&amp; tail&#91;i] == ',') break; \/\/ \u627e\u5230\u8868\u5934\u548c\u8868\u5c3e\u7684\u5206\u754c\u70b9\n\t}\n\tif (i &lt; len) \/\/ \u5b58\u5728\u8868\u5c3e\n\t{\n\t\tSubString(head, tail, 1, i); \/\/ \u5206\u79bb\u51fa\u8868\u5934\uff0c\u8d4b\u503c\u7ed9head\n\t\tSubString(tail, tail, i + 2, len - i - 1); \/\/ \u5c06\u81ea\u5df1\u66f4\u65b0\u4e3a\u8868\u5c3e\n\t}\n\telse \/\/ \u4e0d\u5b58\u5728\u8868\u5c3e\n\t{\n\t\tSubString(head, tail, 1, len); \/\/ \u5168\u90e8\u66f4\u65b0\u4e3a\u8868\u5934\n\t\ttail&#91;0] = 0;\n\t}\n}\n\nvoid Create_General_List(General_List* L, char* str)\n{\n\tif (str == NULL) (*L) = NULL; \/\/ \u4f20\u5165\u4e86\u7a7a\u5b57\u7b26\u4e32\n\telse\n\t{\n\t\t(*L) = (General_List)malloc(sizeof(GNode));\n\t\tif (strlen(str) == 1) \/\/ \u4f20\u5165\u5b57\u7b26\uff0c\u53ea\u80fd\u521b\u5efa\u539f\u5b50\u8282\u70b9\n\t\t{\n\t\t\t(*L)->Tag = 0;\n\t\t\t(*L)->atom = *str;\n\t\t}\n\t\telse \/\/ \u4f20\u5165\u5b57\u7b26\u4e32\uff0c\u521b\u5efalist\u8282\u70b9\n\t\t{\n\t\t\tchar head&#91;100] = { '\\0' };\n\t\t\tSubString(str, str, 2, strlen(str) - 2); \/\/ \u53bb\u9664str\u6700\u5916\u5c42\u62ec\u53f7\n\t\t\tGeneral_List q, p = (*L);\n\t\t\tp->Tag = 1;\n\t\t\tdo\n\t\t\t{\n\t\t\t\tSeperateList(head, str); \/\/ head\u53d8\u6210\u8868\u5934\uff0cstr\u53d8\u6210\u8868\u5c3e\n\t\t\t\tCreate_General_List(&amp;(p->ptr.hp), head); \/\/ \u9012\u5f52\u521b\u5efa\u8868\u5934\n\t\t\t\tif ((*str)!=0) \/\/ \u8868\u5c3e\u975e\u7a7a\uff0c\u5219\u4e0b\u6b21\u5faa\u73af\u7ee7\u7eed\u5c06\u8868\u5c3e\u5206\u5272\u6210\u8868\u5934\u548c\u8868\u5c3e\n\t\t\t\t{\n\t\t\t\t\tq = p;\n\t\t\t\t\tp = (General_List)malloc(sizeof(GNode));\n\t\t\t\t\tp->Tag = 1;\n\t\t\t\t\tq->ptr.tp = p; \/\/ \u5728\u5f53\u524d\u8282\u70b9\u540e\u8fde\u63a5\u5b50\u5c3e\u8868\n\t\t\t\t}\n\t\t\t} while ((*str) != 0);\n\t\t\tp->ptr.tp = NULL;\n\t\t}\n\t}\n}\n\nint Get_List_Deepth(General_List L) \/\/ \u8ba1\u7b97\u8868\u6df1\u5ea6\n{\n\tif (!L) return 1; \/\/ \u7a7a\u8868\u6df1\u5ea6\u4e3a1\n\tif (L->Tag == 0) return 0; \/\/ \u539f\u5b50\u4e0d\u7b97\u5165\u6df1\u5ea6\n\tint max = 0, dep;\n\tfor (General_List t = L; t != NULL; t = t->ptr.tp) \/\/ \u6bcf\u6b21\u5faa\u73af\u8ba9t\u6307\u9488\u6307\u5411\u4e0b\u4e00\u4e2a\u5c3e\u5b50\u8868\n\t{\n\t\tdep = Get_List_Deepth(t->ptr.hp); \/\/ \u9012\u5f52\u8ba1\u7b97\u5934\u5b50\u8868\u6df1\u5ea6\n\t\tmax = max &lt; dep ? dep : max; \/\/ \u66f4\u65b0\u6df1\u5ea6\n\t}\n\treturn max + 1;\n}\n\nvoid Clear_List(General_List* L) \/\/ \u4e3a\u4e86\u5220\u9664\u8868\u9996\u8282\u70b9\uff0c\u9700\u4f20\u5165GNode\u7684\u4e8c\u7ea7\u6307\u9488\n{\n\tif (!(*L)) return; \/\/ L\u662f\u7a7a\u8282\u70b9\n\tif (!((*L)->Tag)) \/\/ \u662f\u539f\u5b50\u8282\u70b9\n\t{\n\t\tfree((*L));\n\t\t(*L) = NULL;\n\t\treturn;\n\t}\n\tClear_List(&amp;((*L)->ptr.hp)); \/\/ \u9012\u5f52\u5220\u9664\u5934\u5b50\u8868\n\tClear_List(&amp;((*L)->ptr.tp)); \/\/ \u9012\u5f52\u5220\u9664\u5c3e\u5b50\u8868\n\tfree(*L); \/\/ \u5220\u9664\u81ea\u8eab\n\t*L = NULL;\n}\nint main()\n{\n\tGeneral_List L;\n\tchar buffer&#91;100];\n\tint num;\n\tprintf(\"\u8bf7\u8f93\u5165\u5e7f\u4e49\u8868\u4e2a\u6570\uff1a\");\n\tscanf(\"%d\", &amp;num);\n\tfor (int i = 1; i &lt;= num; ++i)\n\t{\n\t\tprintf(\"\u8bf7\u8f93\u5165\u5e7f\u4e49\u8868\uff1a\");\n\t\tscanf(\"%s\", buffer);\n\t\tCreate_General_List(&amp;L, buffer);\n\t\tprintf(\"\u7b2c%d\u4e2a\u5e7f\u4e49\u8868\u7684\u6df1\u5ea6\u4e3a\uff1a%d\\n\", i, Get_List_Deepth(L));\n\t\tClear_List(&amp;L);\n\t\tif (!L) printf(\"\u8be5\u5e7f\u4e49\u8868\u5185\u5b58\u5df2\u91ca\u653e\\n\\n\");\n\t\telse\n\t\t{\n\t\t\tprintf(\"\u5185\u5b58\u91ca\u653e\u51fa\u9519\uff0c\u5df2\u9000\u51fa\\n\\n\");\n\t\t}\n\t}\n\treturn 0;\n}\n\/\/ ((a,b,(c,(d,e),f)),g)\n\/\/ (a,(b,(c,(d,(e,(f),(g))))))\n\/\/ (a)\n\/\/ ((((((a),b),c),d),e),f)<\/code><\/pre>\n\n\n\n<p>\u5206\u6790\uff1a<\/p>\n\n\n\n<p class=\"has-text-align-left\">\u5bf9\u4e8e\u9898\u76ee\u6240\u8981\u6c42\u7684\u7b97\u6cd5Get_List_Deepth\u6765\u8bf4\uff0c\u9996\u5148\u5224\u65ad\u5f53\u524d\u5e7f\u4e49\u8868\u662f\u5426\u4e3a\u7a7a\u8868\uff0c\u82e5\u4e3a\u7a7a\u8868\uff0c\u5219\u8bb0\u5176\u6df1\u5ea6\u4e3a1\uff1b\u5176\u6b21\u5224\u65ad\u5f53\u524d\u5e7f\u4e49\u8868\u8282\u70b9\u662f\u5426\u4e3a\u539f\u5b50\uff0c\u539f\u5b50\u4e0d\u8ba1\u5165\u6df1\u5ea6\u3002\u5224\u65ad\u5b8c\u7279\u6b8a\u60c5\u51b5\u540e\uff0c\u5f00\u59cb\u5bf9\u4f20\u5165\u8282\u70b9\u8fdb\u884c\u5faa\u73af\uff0c\u5728\u6bcf\u4e00\u8f6e\u5faa\u73af\u4e2d\uff0c\u9996\u5148\u5bf9\u5176\u5934\u5b50\u8868\u8fdb\u884c\u9012\u5f52\uff0c\u8ba1\u7b97\u4ee5\u5176\u4e3a\u8d77\u70b9\u7684\u5b50\u8868\u6df1\u5ea6\uff0c\u7136\u540e\u66f4\u65b0\u5f53\u524d\u6df1\u5ea6\u7684\u6700\u5927\u503c\uff0c\u5faa\u73af\u7ed3\u675f\u540e\u8f6c\u5411\u5f53\u524d\u8868\u7684\u5c3e\u5b50\u8868\uff0c\u5f00\u59cb\u4e0b\u4e00\u8f6e\u5faa\u73af\u3002\u6b64\u5faa\u73af\u7ed3\u675f\u540e\u5c31\u53ef\u4ee5\u5f97\u5230\u5f53\u524d\u8868\u7684\u5b50\u8868\u7684\u6df1\u5ea6\uff0c\u6700\u540e\u5c06\u5176+1\u5e76\u8fd4\u56de\u5373\u53ef\u3002<\/p>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p>\u4f60\u5728\u5e72\u561b\uff1f\u7b49\u5f85\u6208\u591a\u3002<br>\u6208\u591a\u662f\u8c01\uff1f\u6211\u4e0d\u77e5\u9053\u3002<br>\u4f60\u5728\u5e72\u561b\uff1f\u7b49\u5f85\u6208\u591a\u3002<br>\u6208\u591a\u662f\u8c01\uff1f\u6211\u4e0d\u77e5\u9053\u3002<br><br>\u6211\u5728\u5e72\u561b\uff1f\u7b49\u5f85\u6208\u591a\u3002<\/p><\/blockquote><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u8981\u6c42\u5982\u4e0b\uff1a \u8bb0\u5f55\u4e00\u4e0b\u6b64\u6b21\u5b66\u4e60\u8fc7\u7a0b\uff1a \u4ee3\u7801\uff1a \u5206\u6790\uff1a \u5bf9\u4e8e\u9898\u76ee\u6240\u8981\u6c42\u7684\u7b97\u6cd5Get_List_Deepth\u6765\u8bf4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-530","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/heqiwei.cn\/index.php\/wp-json\/wp\/v2\/posts\/530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/heqiwei.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/heqiwei.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/heqiwei.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/heqiwei.cn\/index.php\/wp-json\/wp\/v2\/comments?post=530"}],"version-history":[{"count":0,"href":"https:\/\/heqiwei.cn\/index.php\/wp-json\/wp\/v2\/posts\/530\/revisions"}],"wp:attachment":[{"href":"https:\/\/heqiwei.cn\/index.php\/wp-json\/wp\/v2\/media?parent=530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/heqiwei.cn\/index.php\/wp-json\/wp\/v2\/categories?post=530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/heqiwei.cn\/index.php\/wp-json\/wp\/v2\/tags?post=530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}