{"id":435,"date":"2012-11-21T15:38:08","date_gmt":"2012-11-21T08:38:08","guid":{"rendered":"http:\/\/blog.kusumoto.co\/?p=435"},"modified":"2012-11-21T17:34:50","modified_gmt":"2012-11-21T10:34:50","slug":"lab_chapter-3-stack","status":"publish","type":"post","link":"https:\/\/oldblog.kusumotolab.com\/?p=435","title":{"rendered":"Lab_Chapter-3 :: Stack"},"content":{"rendered":"<p><strong>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e19\u0e35\u0e49 \u0e08\u0e30\u0e40\u0e1b\u0e47\u0e19\u0e01\u0e32\u0e23\u0e23\u0e27\u0e21\u0e01\u0e32\u0e23\u0e17\u0e33\u0e07\u0e32\u0e19\u0e02\u0e2d\u0e07 Stack \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07\u0e17\u0e31\u0e49\u0e07\u0e01\u0e32\u0e23 pop \u0e41\u0e25\u0e30 push \u0e41\u0e25\u0e49\u0e27\u0e2a\u0e31\u0e48\u0e07\u0e41\u0e2a\u0e14\u0e07\u0e1c\u0e25\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14<\/strong><\/p>\n<p><a href=\"http:\/\/img.kusumoto.co\/show\/580\" target=\"_blank\"><img decoding=\"async\" src=\"http:\/\/img.kusumoto.co\/i\/tlM.jpg\" alt=\"Host by img.kusumoto.co\" \/><\/a><\/p>\n<pre lang=\"c\">\r\n#include <stdio.h>\r\n\/*\r\nKusumoto Computer Coding\r\nhttp:\/\/kusumoto.co\r\n*\/\r\n\r\n\/\/void pop(NODE *head);\r\n\/\/void push(NODE *headNode, char data);\r\n\/\/void PrintStack(NODE *head);\r\ntypedef struct node {\r\n\t\tchar data;\r\n\t\tstruct NODE *next;\r\n\t} NODE;\r\n\t\r\nvoid PrintStack(NODE *head){\r\n\tprintf(\"\\n ---------- Print Stack ------------\\n\");\r\n\twhile(head!=NULL) {\r\n\t\tif(head->data!='H'){\r\n\t\t\tprintf(\" | %c | \\n\",head->data);\r\n\t\t}\r\n\t\t\thead = head->next;\r\n\t\t\r\n\t\t}\r\n\t\tprintf(\"--------------------------\");\r\n\t}\r\n\r\n\r\n\r\nvoid push(NODE *headNode, char data){\r\n\t\/\/create new node stack\r\n\tNODE *newStack;\r\n\tnewStack = (NODE*)malloc(sizeof(NODE));\r\n\t\r\n\t\/\/set data\r\n\tnewStack->data = data;\r\n\t\/\/link new Stack to top node\r\n\tnewStack -> next = headNode->next;\r\n\t\r\n\t\/\/link head to new top node\r\n\theadNode->next = newStack;\r\n\t\r\n\t\/\/print push node\r\n\tprintf(\"\\n Push node | %c | In \\n\",newStack->data);\r\n\tPrintStack(headNode);\r\n}\r\n\r\nvoid pop(NODE *head) {\r\n\t\/\/get top mode\r\n\tNODE *nodePop = head->next;\r\n\t\/\/link head node to next node from top node\r\n\thead->next = nodePop->next;\r\n\t\/\/print pop node\r\n\tprintf(\"\\n Pop node | %c | out \\n\",nodePop->data);\r\n\t\/\/print stack\r\n\tPrintStack(head);\r\n}\r\n\r\nint main() {\r\n\t\r\n\t\/\/ declare head node\r\n\t\tNODE *head;\r\n\t\/\/ allocate the memory\r\n\t\thead = (NODE*)malloc(sizeof(NODE));\r\n\t\/\/set the link to NULL (for now)\r\n\t\thead->next=NULL;\r\n\t\/\/set data\r\n\t\thead->data = 'H';\r\n\t\/\/push node\r\n\tpush(head,'A');\r\n\tpush(head,'B');\r\n\tpush(head,'C');\r\n\tpush(head,'D');\r\n\tpush(head,'E');\r\n\t\/\/pop node\r\n\tpop(head);\r\n\tpop(head);\r\n\tpop(head);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e19\u0e35\u0e49 \u0e08\u0e30\u0e40\u0e1b\u0e47\u0e19\u0e01\u0e32\u0e23\u0e23\u0e27\u0e21\u0e01\u0e32\u0e23\u0e17\u0e33\u0e07\u0e32\u0e19\u0e02\u0e2d\u0e07 Stack \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07\u0e17\u0e31\u0e49\u0e07\u0e01\u0e32\u0e23 pop \u0e41\u0e25\u0e30 push \u0e41\u0e25\u0e49\u0e27\u0e2a\u0e31\u0e48\u0e07\u0e41\u0e2a\u0e14\u0e07\u0e1c\u0e25\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14 #include \/* Kusumoto Computer Coding http:\/\/kusumoto.co *\/ \/\/void pop(NODE *head); \/\/void push(NODE *headNode, char data); \/\/void PrintStack(NODE *head); typedef struct node { char data; struct NODE *next; } NODE; void PrintStack(NODE *head){ printf(&#8220;\\n &#8212;&#8212;&#8212;- Print Stack &#8212;&#8212;&#8212;&#8212;\\n&#8221;); while(head!=NULL) { if(head->data!=&#8217;H&#8217;){ printf(&#8221; | %c | \\n&#8221;,head->data); } head [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[43],"tags":[],"class_list":["post-435","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3OMEb-71","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/435","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=435"}],"version-history":[{"count":3,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/435\/revisions"}],"predecessor-version":[{"id":438,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=\/wp\/v2\/posts\/435\/revisions\/438"}],"wp:attachment":[{"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oldblog.kusumotolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}