{"id":266,"date":"2011-09-14T13:17:16","date_gmt":"2011-09-14T05:17:16","guid":{"rendered":"http:\/\/wangkaixuan.tech\/?p=266"},"modified":"2020-06-06T13:18:36","modified_gmt":"2020-06-06T05:18:36","slug":"%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84_%e9%98%9f%e5%88%97_%e7%94%a8%e9%93%be%e8%a1%a8%e5%8a%a8%e6%80%81%e5%bb%ba%e7%ab%8b%e9%87%8a%e6%94%be%e8%8a%82%e7%82%b9%e5%ae%9e%e7%8e%b0%e9%98%9f%e5%88%97%e5%90%84","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=266","title":{"rendered":"\u6570\u636e\u7ed3\u6784_\u961f\u5217_\u7528\u94fe\u8868\u52a8\u6001\u5efa\u7acb\u91ca\u653e\u8282\u70b9\u5b9e\u73b0\u961f\u5217\u5404\u79cd\u64cd\u4f5c_C++\u5b9e\u73b0"},"content":{"rendered":"\n<p>mqueue.h<\/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 QUEUE\n{\npublic:\n\tQUEUE();\n\tvoid Push();\n\tvoid Pop();\n\tvoid Front();\n\tvoid Length();\nprivate:\n\tNODE *front, *rear, *keep;\n\tint len;\n};\n\nQUEUE::QUEUE()\n{\n\tkeep = front = rear = NULL;\n\tlen = 0;\n}\n\nvoid QUEUE::Pop()\n{\n\tcout &lt;&lt; \"Pop Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tif (front == rear)\n\t{\n\t\tif (front == NULL)\n\t\t\tcout &lt;&lt; \"Queue Empty !\" &lt;&lt; endl &lt;&lt; endl;\n\t\telse\n\t\t{\n\t\t\tdelete front;\n\t\t\tfront = rear = NULL;\n\t\t\tlen--;\n\t\t}\n\t}\n\telse\n\t{\n\t\tkeep = front->next;\n\t\tdelete front;\n\t\tfront = keep;\n\t\tlen--;\n\t}\n}\n\nvoid QUEUE::Push()\n{\n\tcout &lt;&lt; \"Push Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tint num;\n\tcout &lt;&lt; \"Please Input The Number You Want To Push In This Queue :\" &lt;&lt; endl\n\t\t\t&lt;&lt; endl;\n\tcin >> num;\n\tif (rear == NULL)\n\t\tfront = rear = new NODE;\n\telse\n\t{\n\t\trear->next = new NODE;\n\t\trear = rear->next;\n\t}\n\trear->num = num;\n\tlen++;\n}\n\nvoid QUEUE::Front()\n{\n\tcout &lt;&lt; \"Front Called !\" &lt;&lt; endl &lt;&lt; endl;\n\tif (front == NULL)\n\t{\n\t\tcout &lt;&lt; \"Queue Empty !\" &lt;&lt; endl &lt;&lt; endl;\n\t\treturn;\n\t}\n\tcout &lt;&lt; \"The Element At The Top Of The Queue Is : \" &lt;&lt; front->num &lt;&lt; endl\n\t\t\t&lt;&lt; endl;\n}\n\nvoid QUEUE::Length()\n{\n\tcout &lt;&lt; \"The Length Of This Queue Is : \" &lt;&lt; len &lt;&lt; endl &lt;&lt; endl;\n}\n<\/code><\/pre>\n\n\n\n<p>main.cpp<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include\"mqueue.h\"\nusing namespace std;\n\nint main()\n{\n\tQUEUE q;\n\tchar choice;\n\twhile (1)\n\t{\n\t\tcout &lt;&lt; \"Your Choice , Please :\" &lt;&lt; endl &lt;&lt; endl &lt;&lt; \"1 . Push\" &lt;&lt; endl\n\t\t\t\t&lt;&lt; \"2 . Pop\" &lt;&lt; endl &lt;&lt; \"3 . Length\" &lt;&lt; endl &lt;&lt; \"4 . Front\"\n\t\t\t\t&lt;&lt; endl &lt;&lt; endl;\n\t\tcin >> choice;\n\t\tswitch (choice)\n\t\t{\n\t\tcase '1':\n\t\t\tq.Push();\n\t\t\tbreak;\n\t\tcase '2':\n\t\t\tq.Pop();\n\t\t\tbreak;\n\t\tcase '3':\n\t\t\tq.Length();\n\t\t\tbreak;\n\t\tcase '4':\n\t\t\tq.Front();\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tcout &lt;&lt; \"Please Input The Right Choice As Shown Above !\" &lt;&lt; endl\n\t\t\t\t\t&lt;&lt; endl;\n\t\t\tbreak;\n\t\t}\n\t}\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>mqueue.h main.cpp<\/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-266","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\/266","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=266"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}