{"id":659,"date":"2019-06-09T08:58:06","date_gmt":"2019-06-09T00:58:06","guid":{"rendered":"http:\/\/fankasy.xyz\/?p=659"},"modified":"2019-09-25T09:01:09","modified_gmt":"2019-09-25T01:01:09","slug":"noj1020-%e5%b1%82%e6%ac%a1%e9%81%8d%e5%8e%86%e4%ba%8c%e5%8f%89%e6%a0%91","status":"publish","type":"post","link":"http:\/\/fankasy.xyz\/index.php\/2019\/06\/09\/noj1020-%e5%b1%82%e6%ac%a1%e9%81%8d%e5%8e%86%e4%ba%8c%e5%8f%89%e6%a0%91\/","title":{"rendered":"NOJ1020 \u5c42\u6b21\u904d\u5386\u4e8c\u53c9\u6811"},"content":{"rendered":"<pre>#include&lt;stdio.h&gt;\r\n#include&lt;stdlib.h&gt;\r\n#define NN 50\r\n\r\n\r\ntypedef struct BinaryTreeNode\r\n{\r\n    char Data;\r\n    struct BinaryTreeNode* lChild, * rChild;\r\n}BinaryTreeNode;\r\ntypedef BinaryTreeNode* BiTree;\r\n\r\ntypedef struct BinaryTree {\r\n    BinaryTreeNode* root;\r\n}BinaryTree;\r\n\r\ntypedef struct {\r\n    BiTree data[NN];\r\n    int front; \/\/\u5934\u6307\u9488\r\n    int rear;\/\/\u5c3e\u6307\u9488\uff0c\u961f\u5217\u975e\u7a7a\u65f6\uff0c\u6307\u5411\u961f\u5c3e\u5143\u7d20\u7684\u4e0b\u4e00\u4e2a\u4f4d\u7f6e\r\n    int num;\/\/\u8ba1\u91cf\r\n}SqQueue;\r\n\r\n\r\nvoid Quenein(BiTree Biquene, SqQueue* Q)\r\n{\r\n    if (Q-&gt;num == NN)\r\n        return;\r\n    Q-&gt;data[Q-&gt;front % NN] = Biquene;\r\n    Q-&gt;front++;\r\n    Q-&gt;num++;\r\n}\r\n\r\nBiTree Queneout(SqQueue * Q)\r\n{\r\n    if (Q-&gt;num == 0)\r\n        return 0;\r\n    Q-&gt;rear++;\r\n    Q-&gt;num--;\r\n    return Q-&gt;data[(Q-&gt;rear - 1) % NN];\r\n}\r\n\r\n\r\n\r\nBinaryTreeNode* PreCreateBt(BinaryTreeNode * t)\r\n{\r\n    char ch;\r\n    ch = getchar();\r\n    getchar();\r\n    if (ch == '#')\r\n        t = NULL;\r\n    else\r\n    {\r\n       t = malloc(sizeof(BinaryTreeNode));\r\n        t-&gt;Data = ch;\r\n        t-&gt;lChild = PreCreateBt(t-&gt;lChild);\r\n        t-&gt;rChild = PreCreateBt(t-&gt;rChild);\r\n    }\r\n    return t;\r\n}\r\n\r\n\r\nint main()\r\n{\r\n    BinaryTree myTree;\r\n    SqQueue Q;\r\n    Q.front = 0; Q.rear = 0; Q.num = 0;\r\n    myTree.root = NULL;\r\n    myTree.root = PreCreateBt(myTree.root);\r\n    printf(\"LevelOrder:\");\r\n    Quenein(myTree.root, &amp;Q);\r\n    BiTree temp = NULL;\r\n    if (myTree.root == 0)\r\n        return 0;\r\n    while (Q.num != 0)\r\n    {\r\n        temp = Queneout(&amp;Q);\r\n        if (temp == NULL)\r\n            break;\r\n        printf(\" %c\", temp-&gt;Data);\r\n        \/\/printf(\"Fuck you memory limit exceed\");\r\n        if (temp-&gt;lChild != NULL)\r\n            Quenein(temp-&gt;lChild, &amp;Q);\r\n        if (temp-&gt;rChild != NULL)\r\n            Quenein(temp-&gt;rChild, &amp;Q);\r\n    }\r\n    \/\/printf(\"sb\");\r\n    return 0;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #defin [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[],"_links":{"self":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/posts\/659"}],"collection":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=659"}],"version-history":[{"count":0,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/posts\/659\/revisions"}],"wp:attachment":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=659"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}