{"id":284,"date":"2011-09-24T13:47:38","date_gmt":"2011-09-24T05:47:38","guid":{"rendered":"http:\/\/wangkaixuan.tech\/?p=284"},"modified":"2020-06-06T13:51:33","modified_gmt":"2020-06-06T05:51:33","slug":"%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84_%e5%9b%be_%e5%bb%ba%e7%ab%8b%e5%8d%81%e5%ad%97%e9%93%be%e8%a1%a8%e6%b1%82%e6%9c%89%e5%90%91%e5%9b%be%e4%b8%ad%e6%af%8f%e4%b8%aa%e9%a1%b6%e7%82%b9%e7%9a%84%e5%85%a5","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=284","title":{"rendered":"\u6570\u636e\u7ed3\u6784_\u56fe_\u5efa\u7acb\u5341\u5b57\u94fe\u8868\u6c42\u6709\u5411\u56fe\u4e2d\u6bcf\u4e2a\u9876\u70b9\u7684\u5165\u5ea6\u51fa\u5ea6\u5e76\u8f93\u51fa\u548c\u5b83\u76f8\u5173\u7684\u5f27_C++\u5b9e\u73b0"},"content":{"rendered":"\n<p>\u793a\u4f8b\u8f93\u5165\uff1a<\/p>\n\n\n\n<p>a b c d            \/\/\u6bcf\u4e2a\u9876\u70b9\u7684\u540d\u5b57 char\u578b<br>(CTRL+Z)       \/\/\u6807\u793a\u8f93\u5165\u7ed3\u675f<br>7                     \/\/\u6709\u5411\u56fe\u4e2d\u5f27\u7684\u4e2a\u6570<br>0 1                  \/\/\u8be5\u6570\u5bf9\u4ee3\u8868\u4ece\u7f16\u53f7\u4e3a0\u7684\u9876\u70b9\u5230\u7f16\u53f7\u4e3a1\u7684\u9876\u70b9\u4e4b\u95f4\u6709\u4e00\u6761\u5f27 0->1 \u4e0b\u540c<br>0 2                  \/\/a\u3001b\u3001c\u3001d\u7f16\u53f7\u5206\u522b\u4e3a0\u30011\u30012\u30013<br>2 0<br>2 3<br>3 0<br>3 1<br>3 2<\/p>\n\n\n\n<p>\u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"200\" height=\"453\" src=\"http:\/\/wangkaixuan.tech\/wp-content\/uploads\/2020\/06\/1-1.jpg\" alt=\"\" class=\"wp-image-285\" srcset=\"http:\/\/www.wangkaixuan.tech\/wp-content\/uploads\/2020\/06\/1-1.jpg 200w, http:\/\/www.wangkaixuan.tech\/wp-content\/uploads\/2020\/06\/1-1-132x300.jpg 132w, http:\/\/www.wangkaixuan.tech\/wp-content\/uploads\/2020\/06\/1-1-119x270.jpg 119w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/figure>\n\n\n\n<p>\u6709\u5411\u56fe\u793a\u4f8b<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"236\" height=\"227\" src=\"http:\/\/wangkaixuan.tech\/wp-content\/uploads\/2020\/06\/1-2.jpg\" alt=\"\" class=\"wp-image-287\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"766\" height=\"270\" src=\"http:\/\/wangkaixuan.tech\/wp-content\/uploads\/2020\/06\/2-1.jpg\" alt=\"\" class=\"wp-image-286\" srcset=\"http:\/\/www.wangkaixuan.tech\/wp-content\/uploads\/2020\/06\/2-1.jpg 766w, http:\/\/www.wangkaixuan.tech\/wp-content\/uploads\/2020\/06\/2-1-300x106.jpg 300w, http:\/\/www.wangkaixuan.tech\/wp-content\/uploads\/2020\/06\/2-1-604x213.jpg 604w\" sizes=\"auto, (max-width: 766px) 100vw, 766px\" \/><\/figure>\n\n\n\n<p>head.h<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#define MAX_VERTEX_NUM 20\nusing namespace std;\n\nclass ArcBox \/\/\u5f27\n{\npublic:\n\tArcBox();\n\tint tailvex, headvex;\n\tArcBox *hlink, *tlink;\n\tchar info;\n};\n\nArcBox::ArcBox()\n{\n\ttailvex = headvex = 0;\n\thlink = tlink = NULL;\n}\n\nclass VexNode \/\/\u9876\u70b9\n{\npublic:\n\tVexNode();\n\tchar data;\n\tArcBox *firstin, *firstout;\n};\n\nVexNode::VexNode()\n{\n\tfirstin = firstout = NULL;\n}\n\nclass OlGraphMessage \/\/\u5341\u5b57\u94fe\u8868\u76f8\u5173\n{\npublic:\n\tOlGraphMessage();\n\tVexNode xlist&#91;MAX_VERTEX_NUM];\n\tint vexnum, arcnum;\n};\n\nOlGraphMessage::OlGraphMessage()\n{\n\tvexnum = arcnum = 0;\n}\n\nclass OLGRAPH\n{\npublic:\n\tvoid OlGraphConstructor(); \/\/\u5efa\u7acb\u5341\u5b57\u94fe\u8868\nprivate:\n\tvoid GetVertex(); \/\/\u5f97\u5230\u9876\u70b9\u4fe1\u606f\n\tvoid GetArcNum(); \/\/\u5f97\u5230\u5f27\u5ea6\u6570\n\tvoid CreatOl(); \/\/\u6839\u636e\u9876\u70b9\u4fe1\u606f\u5efa\u7acb\u5341\u5b57\u94fe\u8868\n\tvoid OlPrinter(); \/\/\u8f93\u51fa\u9876\u70b9\u4fe1\u606f\n\tOlGraphMessage ol;\n};\n\nvoid OLGRAPH::OlGraphConstructor()\n{\n\tcout &lt;&lt; \"OlGraphConstructor Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tGetVertex(); \/\/\u5f97\u5230\u9876\u70b9\u4fe1\u606f\n\tGetArcNum(); \/\/\u5f97\u5230\u5f27\u5ea6\u6570\n\tCreatOl(); \/\/\u6839\u636e\u9876\u70b9\u4fe1\u606f\u5efa\u7acb\u5341\u5b57\u94fe\u8868\n\tOlPrinter(); \/\/\u8f93\u51fa\u9876\u70b9\u4fe1\u606f\n}\n\nvoid OLGRAPH::GetVertex() \/\/\u5f97\u5230\u9876\u70b9\u4fe1\u606f\n{\n\tcout &lt;&lt; \"GetVertex Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tcout &lt;&lt; \"Please Enter The Vertex\" &lt;&lt; endl &lt;&lt; endl;\n\twhile (cin >> ol.xlist&#91;ol.vexnum].data)\n\t\tol.vexnum++;\n\tcin.clear();\n}\n\nvoid OLGRAPH::GetArcNum() \/\/\u5f97\u5230\u5f27\u5ea6\u6570\n{\n\tcout &lt;&lt; \"GetArcNum Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tcout &lt;&lt; \"Please Enter The Number Of The Arc\" &lt;&lt; endl &lt;&lt; endl;\n\tcin >> ol.arcnum;\n}\nvoid OLGRAPH::CreatOl() \/\/\u6839\u636e\u9876\u70b9\u4fe1\u606f\u5efa\u7acb\u5341\u5b57\u94fe\u8868\n{\n\tcout &lt;&lt; \"CreatOl Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tcout &lt;&lt; \"Please Input The ArcMessage :\" &lt;&lt; endl &lt;&lt; endl;\n\tint a, b;\n\tArcBox *insert, *p;\n\twhile (ol.arcnum--)\n\t{\n\t\tcin >> a >> b;\n\t\tinsert = new ArcBox;\n\t\tinsert->headvex = a;\n\t\tinsert->tailvex = b;\n\t\tp = ol.xlist&#91;a].firstout;\n\t\tif (p == NULL)\n\t\t{\n\t\t\tol.xlist&#91;a].firstout = insert;\n\t\t}\n\t\telse\n\t\t{\n\t\t\twhile (p->tlink != NULL)\n\t\t\t\tp = p->tlink;\n\t\t\tp->tlink = insert;\n\t\t}\n\t\tp = ol.xlist&#91;b].firstin;\n\t\tif (p == NULL)\n\t\t{\n\t\t\tol.xlist&#91;b].firstin = insert;\n\t\t}\n\t\telse\n\t\t{\n\t\t\twhile (p->hlink != NULL)\n\t\t\t\tp = p->hlink;\n\t\t\tp->hlink = insert;\n\t\t}\n\t}\n\tcout &lt;&lt; \"CreatOl Succeed !\" &lt;&lt; endl &lt;&lt; endl;\n}\n\nvoid OLGRAPH::OlPrinter() \/\/\u8f93\u51fa\u9876\u70b9\u4fe1\u606f\n{\n\tcout &lt;&lt; \"OlPrinter Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tArcBox *p;\n\tint od, id;\n\tfor (int i = 0; i &lt; ol.vexnum; i++)\n\t{\n\t\tcout &lt;&lt; ol.xlist&#91;i].data &lt;&lt; \" : \" &lt;&lt; endl; \/\/\u8f93\u51fa\u9876\u70b9\n\t\tod = id = 0; \/\/\u521d\u59cb\u5316\u51fa\u5ea6\u548c\u5165\u5ea6\n\t\t\/\/\u6c42\u4ee5\u8be5\u9876\u70b9\u4e3a\u5f27\u5c3e\u7684\u5f27\n\t\tp = ol.xlist&#91;i].firstout;\n\t\twhile (p != NULL)\n\t\t{\n\t\t\tcout &lt;&lt; ol.xlist&#91;p->headvex].data &lt;&lt; \"->\"\n\t\t\t\t\t&lt;&lt; ol.xlist&#91;p->tailvex].data &lt;&lt; endl;\n\t\t\tp = p->tlink;\n\t\t\tod++;\n\t\t}\n\t\tcout &lt;&lt; \"OutDegree = \" &lt;&lt; od &lt;&lt; endl;\n\t\t\/\/\u6c42\u4ee5\u8be5\u9876\u70b9\u4e3a\u5f27\u5934\u7684\u5f27\n\t\tp = ol.xlist&#91;i].firstin;\n\t\twhile (p != NULL)\n\t\t{\n\t\t\tcout &lt;&lt; ol.xlist&#91;p->tailvex].data &lt;&lt; \"&lt;-\"\n\t\t\t\t\t&lt;&lt; ol.xlist&#91;p->headvex].data &lt;&lt; endl;\n\t\t\tp = p->hlink;\n\t\t\tid++;\n\t\t}\n\t\tcout &lt;&lt; \"InDegree = \" &lt;&lt; id &lt;&lt; endl;\n\t}\n}\n<\/code><\/pre>\n\n\n\n<p>main.cpp<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include\"head.h\"\nint main()\n{\n\tOLGRAPH ol;\n\tol.OlGraphConstructor();\n\tsystem(\"pause\");\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u793a\u4f8b\u8f93\u5165\uff1a a b c d \/\/\u6bcf\u4e2a\u9876\u70b9\u7684\u540d\u5b57 char\u578b(CTRL+Z) \/\/\u6807\u793a\u8f93\u5165\u7ed3\u675f7 \/\/\u6709\u5411\u56fe\u4e2d\u5f27\u7684\u4e2a\u65700 1 \/\/\u8be5\u6570\u5bf9\u4ee3\u8868\u4ece\u7f16\u53f7\u4e3a0\u7684\u9876\u70b9\u5230\u7f16\u53f7&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"http:\/\/www.wangkaixuan.tech\/?p=284\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-284","post","type-post","status-publish","format-standard","hentry","category-06-02-"],"_links":{"self":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=284"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/284\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=284"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}