{"id":260,"date":"2011-09-13T13:11:11","date_gmt":"2011-09-13T05:11:11","guid":{"rendered":"http:\/\/wangkaixuan.tech\/?p=260"},"modified":"2020-06-06T13:13:10","modified_gmt":"2020-06-06T05:13:10","slug":"%e6%9e%84%e9%80%a0%e9%93%be%e8%a1%a8abc%ef%bc%8c%e5%88%a0%e9%99%a4%e5%9c%a8a%e4%b8%ad%e7%9a%84abc%e7%9a%84%e5%85%ac%e5%85%b1%e5%85%83%e7%b4%a0_c%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=260","title":{"rendered":"\u6784\u9020\u94fe\u8868ABC\uff0c\u5220\u9664\u5728A\u4e2d\u7684ABC\u7684\u516c\u5171\u5143\u7d20_C++\u5b9e\u73b0"},"content":{"rendered":"\n<p>\u201chead.h\u201d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\nusing namespace std;\n\nclass NODE\n{\npublic:\n\tNODE();\n\tint num;\n\tNODE *next;\n};\n\nNODE::NODE()\n{\n\tnum = 0;\n\tnext = NULL;\n}\n\nclass DATA\n{\npublic:\n\tDATA();\n\tvoid Constructor();\n\tvoid Print();\n\tvoid Process();\nprivate:\n\tNODE *head1, *head2, *head3, *p, *pr, *keep;\n\tint first;\n};\n\nDATA::DATA()\n{\n\thead1 = head2 = head3 = p = pr = keep = NULL;\n\tfirst = 1;\n}\n\nvoid DATA::Constructor()\n{\n\tif (first &lt;= 3)\n\t{\n\t\tcout &lt;&lt; \"Constructor \" &lt;&lt; first &lt;&lt; \" called !\" &lt;&lt; endl;\n\t}\n\telse\n\t\treturn;\n\tcout &lt;&lt; \"How Many Numbers Do You Want To Enter ?\" &lt;&lt; endl &lt;&lt; endl;\n\tint nnum, input;\n\tcin >> nnum;\n\tif (nnum != 0)\n\t{\n\t\tp = new NODE;\n\t\tcin >> input;\n\t\tp->num = input;\n\t\tswitch (first)\n\t\t{\n\t\tcase 1:\n\t\t\thead1 = p;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\thead2 = p;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\thead3 = p;\n\t\t\tbreak;\n\t\t}\n\t\tnnum--;\n\t}\n\twhile (nnum--)\n\t{\n\t\tp->next = new NODE;\n\t\tp = p->next;\n\t\tcin >> input;\n\t\tp->num = input;\n\t}\n\tp->next = NULL;\n\tfirst++;\n}\n\nvoid DATA::Print()\n{\n\tcout &lt;&lt; \"Print called !\" &lt;&lt; endl &lt;&lt; endl;\n\tp = head1;\n\tif (p == NULL)\n\t\tcout &lt;&lt; \"No Data !\" &lt;&lt; endl;\n\twhile (p != NULL)\n\t{\n\t\tcout &lt;&lt; p->num &lt;&lt; endl;\n\t\tp = p->next;\n\t}\n\tcout &lt;&lt; endl;\n}\n\nvoid DATA::Process()\n{\n\tcout &lt;&lt; \"Processor called !\" &lt;&lt; endl &lt;&lt; endl;\n\tpr = p = head1;\n\twhile (head2 != NULL &amp;&amp; head3 != NULL)\n\t{\n\t\tif (head2->num &lt; p->num)\n\t\t{\n\t\t\tkeep = head2;\n\t\t\thead2 = head2->next;\n\t\t\tdelete keep;\n\t\t}\n\t\tif (head3->num &lt; p->num)\n\t\t{\n\t\t\tkeep = head3;\n\t\t\thead3 = head3->next;\n\t\t\tdelete keep;\n\t\t}\n\t\tif (head2 == NULL || head3 == NULL)\n\t\t\treturn;\n\t\tif (head2->num == p->num &amp;&amp; head3->num == p->num)\n\t\t{\n\t\t\tif (p == head1)\n\t\t\t{\n\t\t\t\thead1 = head1->next;\n\t\t\t\tdelete p;\n\t\t\t\tp = pr = head1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tpr->next = p->next;\n\t\t\t\tdelete p;\n\t\t\t\tp = pr->next;\n\t\t\t}\n\t\t\tif (p == NULL)\n\t\t\t\treturn;\n\t\t}\n\t\tif ((head2->num >= p->num &amp;&amp; head3->num > p->num)\n\t\t\t\t|| (head2->num > p->num &amp;&amp; head3->num >= p->num))\n\t\t{\n\t\t\tpr = p;\n\t\t\tp = p->next;\n\t\t\tif (p == NULL)\n\t\t\t\treturn;\n\t\t}\n\t}\n}\n<\/code><\/pre>\n\n\n\n<p>\u201cmain.cpp\u201d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include\"head.h\"\nusing namespace std;\n \nint main()\n{\n\tDATA data;\n\tdata.Constructor();\n\tdata.Constructor();\n\tdata.Constructor();\n\tdata.Process();\n\tdata.Print();\n\tsystem(\"pause\");\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u201chead.h\u201d \u201cmain.cpp\u201d<\/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-260","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\/260","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=260"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/260\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=260"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}