{"id":48,"date":"2013-10-25T14:34:29","date_gmt":"2013-10-25T14:34:29","guid":{"rendered":""},"modified":"2013-10-25T14:34:29","modified_gmt":"2013-10-25T14:34:29","slug":"","status":"publish","type":"post","link":"http:\/\/weizn.net\/?p=48","title":{"rendered":"Queue"},"content":{"rendered":"<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\n#include &lt;conio.h&gt;<br \/>\n#include &lt;windows.h&gt;<\/p>\n<p>#define DATATYPE int<br \/>\n#define FORM &#8220;%d&#8221;<\/p>\n<p>typedef struct Queue_Node<br \/>\n{<br \/>\n&nbsp;&nbsp;&nbsp; DATATYPE data;<br \/>\n&nbsp;&nbsp;&nbsp; struct Queue_Node *next;<br \/>\n} QNode;<\/p>\n<p>typedef struct<br \/>\n{<br \/>\n&nbsp;&nbsp;&nbsp; QNode *head;<br \/>\n&nbsp;&nbsp;&nbsp; QNode *end;<br \/>\n&nbsp;&nbsp;&nbsp; int queuesize;<br \/>\n} Queue;<\/p>\n<p>\nBOOL EnQueue(Queue *Q,DATATYPE Elem)<br \/>\n{<br \/>\n&nbsp;&nbsp;&nbsp; if(!Q) return FALSE;<\/p>\n<p>&nbsp;&nbsp;&nbsp; if(!Q-&gt;head)<br \/>\n&nbsp;&nbsp;&nbsp; {<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/\u961f\u5217\u5934\u7ed3\u70b9\u4e3a\u7a7a<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Q-&gt;head=Q-&gt;end=(QNode *)malloc(sizeof(QNode));<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(Q-&gt;head==NULL) return FALSE;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memset(Q-&gt;head,NULL,sizeof(QNode));<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Q-&gt;head-&gt;data=Elem;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Q-&gt;queuesize++;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return TRUE;<br \/>\n&nbsp;&nbsp;&nbsp; }<br \/>\n&nbsp;&nbsp;&nbsp; Q-&gt;end-&gt;next=(QNode *)malloc(sizeof(QNode));<br \/>\n&nbsp;&nbsp;&nbsp; if(Q-&gt;end-&gt;next==NULL) return FALSE;<br \/>\n&nbsp;&nbsp;&nbsp; memset(Q-&gt;end-&gt;next,NULL,sizeof(QNode));<br \/>\n&nbsp;&nbsp;&nbsp; Q-&gt;end=Q-&gt;end-&gt;next;<br \/>\n&nbsp;&nbsp;&nbsp; Q-&gt;end-&gt;data=Elem;<br \/>\n&nbsp;&nbsp;&nbsp; Q-&gt;queuesize++;<\/p>\n<p>&nbsp;&nbsp;&nbsp; return TRUE;<br \/>\n}<\/p>\n<p>BOOL DeQueue(Queue *Q,DATATYPE *Elem)<br \/>\n{<br \/>\n&nbsp;&nbsp;&nbsp; if(!Q || !Q-&gt;head) return FALSE;<br \/>\n&nbsp;&nbsp;&nbsp; QNode *temp=Q-&gt;head;<\/p>\n<p>&nbsp;&nbsp;&nbsp; Q-&gt;queuesize&#8211;;&nbsp;&nbsp; \/\/\u961f\u5217\u957f\u5ea6\u51cf\u4e00<br \/>\n&nbsp;&nbsp;&nbsp; *Elem=Q-&gt;head-&gt;data;<br \/>\n&nbsp;&nbsp;&nbsp; Q-&gt;head=Q-&gt;head-&gt;next;<br \/>\n&nbsp;&nbsp;&nbsp; free(temp);<\/p>\n<p>&nbsp;&nbsp;&nbsp; return TRUE;<br \/>\n}<\/p>\n<p>BOOL QueueEmpty(Queue *Q)<br \/>\n{<br \/>\n&nbsp;&nbsp;&nbsp; return Q-&gt;head==NULL?TRUE:FALSE;<br \/>\n}<\/p>\n<p>\nint main(int argc, char* argv[])<br \/>\n{<br \/>\n&nbsp;&nbsp;&nbsp; Queue Q;<br \/>\n&nbsp;&nbsp;&nbsp; DATATYPE elem;<br \/>\n&nbsp;&nbsp;&nbsp; memset(&amp;Q,NULL,sizeof(Queue));<\/p>\n<p>&nbsp;&nbsp;&nbsp; puts(&#8220;\u5165\u961f:&#8221;);<br \/>\n&nbsp;&nbsp;&nbsp; while(1)<br \/>\n&nbsp;&nbsp;&nbsp; {<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(scanf(FORM,&amp;elem)!=1) break;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!EnQueue(&amp;Q,elem))<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&#8220;\u5165\u961f\u5931\u8d25\u3002\\n&#8221;);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _getch();<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>\n&nbsp;&nbsp;&nbsp; }<\/p>\n<p>&nbsp;&nbsp;&nbsp; puts(&#8220;\u51fa\u961f:&#8221;);<br \/>\n&nbsp;&nbsp;&nbsp; while(!QueueEmpty(&amp;Q))<br \/>\n&nbsp;&nbsp;&nbsp; {<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DeQueue(&amp;Q,&amp;elem);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(FORM,elem);<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&#8221; &#8220;);<\/p>\n<p>&nbsp;&nbsp;&nbsp; }<br \/>\n&nbsp;&nbsp;&nbsp; _getch();<\/p>\n<p>&nbsp;&nbsp;&nbsp; return 0;<br \/>\n}<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;stdlib.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\n#include &lt;conio.h&gt;<br \/>\n#include &lt;windows.h&gt;<\/p>\n<p>#define DATATYPE int<br \/>\n#define FORM &#8220;%d&#8221;<\/p>\n<p>typedef struct<br \/>\n{<br \/>\n&nbsp;&nbsp;&amp;nb&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[326],"tags":[],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Queue - Wayne&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/weizn.net\/?p=48\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Queue - Wayne&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;conio.h&gt; #include &lt;windows.h&gt; #define DATATYPE int #define FORM &quot;%d&quot; typedef struct { &nbsp;&nbsp;&amp;nb...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/weizn.net\/?p=48\" \/>\n<meta property=\"og:site_name\" content=\"Wayne&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2013-10-25T14:34:29+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"zinan\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/weizn.net\/#website\",\"url\":\"http:\/\/weizn.net\/\",\"name\":\"Wayne&#039;s Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/weizn.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/weizn.net\/?p=48#webpage\",\"url\":\"http:\/\/weizn.net\/?p=48\",\"name\":\"Queue - Wayne&#039;s Blog\",\"isPartOf\":{\"@id\":\"http:\/\/weizn.net\/#website\"},\"datePublished\":\"2013-10-25T14:34:29+00:00\",\"dateModified\":\"2013-10-25T14:34:29+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/weizn.net\/?p=48#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/weizn.net\/?p=48\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/weizn.net\/?p=48#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\\u9996\\u9875\",\"item\":\"http:\/\/weizn.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Queue\"}]},{\"@type\":\"Article\",\"@id\":\"http:\/\/weizn.net\/?p=48#article\",\"isPartOf\":{\"@id\":\"http:\/\/weizn.net\/?p=48#webpage\"},\"author\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"headline\":\"Queue\",\"datePublished\":\"2013-10-25T14:34:29+00:00\",\"dateModified\":\"2013-10-25T14:34:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/weizn.net\/?p=48#webpage\"},\"wordCount\":492,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\"},\"articleSection\":[\"\\u6570\\u636e\\u7ed3\\u6784\\u53ca\\u7b97\\u6cd5\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/weizn.net\/?p=48#respond\"]}]},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264\",\"name\":\"zinan\",\"logo\":{\"@id\":\"http:\/\/weizn.net\/#personlogo\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Queue - Wayne&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/weizn.net\/?p=48","og_locale":"zh_CN","og_type":"article","og_title":"Queue - Wayne&#039;s Blog","og_description":"#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;conio.h&gt; #include &lt;windows.h&gt; #define DATATYPE int #define FORM \"%d\" typedef struct { &nbsp;&nbsp;&amp;nb...","og_url":"http:\/\/weizn.net\/?p=48","og_site_name":"Wayne&#039;s Blog","article_published_time":"2013-10-25T14:34:29+00:00","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"zinan","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"http:\/\/weizn.net\/#website","url":"http:\/\/weizn.net\/","name":"Wayne&#039;s Blog","description":"","publisher":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/weizn.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"http:\/\/weizn.net\/?p=48#webpage","url":"http:\/\/weizn.net\/?p=48","name":"Queue - Wayne&#039;s Blog","isPartOf":{"@id":"http:\/\/weizn.net\/#website"},"datePublished":"2013-10-25T14:34:29+00:00","dateModified":"2013-10-25T14:34:29+00:00","breadcrumb":{"@id":"http:\/\/weizn.net\/?p=48#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/weizn.net\/?p=48"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/weizn.net\/?p=48#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/weizn.net\/"},{"@type":"ListItem","position":2,"name":"Queue"}]},{"@type":"Article","@id":"http:\/\/weizn.net\/?p=48#article","isPartOf":{"@id":"http:\/\/weizn.net\/?p=48#webpage"},"author":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"headline":"Queue","datePublished":"2013-10-25T14:34:29+00:00","dateModified":"2013-10-25T14:34:29+00:00","mainEntityOfPage":{"@id":"http:\/\/weizn.net\/?p=48#webpage"},"wordCount":492,"commentCount":0,"publisher":{"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264"},"articleSection":["\u6570\u636e\u7ed3\u6784\u53ca\u7b97\u6cd5"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/weizn.net\/?p=48#respond"]}]},{"@type":["Person","Organization"],"@id":"http:\/\/weizn.net\/#\/schema\/person\/e88bc12c590502d8b6249326f960b264","name":"zinan","logo":{"@id":"http:\/\/weizn.net\/#personlogo"}}]}},"_links":{"self":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=48"}],"version-history":[{"count":0,"href":"http:\/\/weizn.net\/index.php?rest_route=\/wp\/v2\/posts\/48\/revisions"}],"wp:attachment":[{"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/weizn.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}