In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to use C++ to achieve additional withdrawal". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Coding environment: VS2019
The retracement function realized by using the chain stack.
LinkStack.h
# implementation of pragma once/*** chain stack * * / # ifdef _ cplusplusextern "C" {# endif # include # include # includeusing namespace std; # define OK 1#define ERROR 0#define OVERFLOW-2//typedef int Data; struct Point {int r; int c; int data;}; typedef struct _ State {Point pos [3];} Data,State; typedef struct StackNode {Data data; struct StackNode* next;} StackNode, * LinkStack / / initialization of algorithm 1 chain stack (headless node) void InitStack (LinkStack& S) {/ / construct an empty stack S, stack top pointer empty S = NULL; / / return OK;} / / algorithm 2 chain stack void Push (LinkStack& S, Data e) {/ / insert element e LinkStack p; p = new StackNode; / / generate a new node p-> data = e at the top of the stack / / set the new node data field to e p-> next = S; / / insert the new node into the top of the stack (similar to pre-interpolation, except without a header node) S = p; / modify the top pointer of the stack to p printf ("ok\ n"); / / return OK } / / algorithm 3 void Pop (LinkStack& S) {/ / delete the top element of S and return its value LinkStack p; if (S = = NULL) return with e; / empty / / e = S-> data; / / assign the top element to e p = S; / / use p to temporarily save the top element space in case S = S-> next is released / / modify the top pointer delete p; / / release the space of the elements at the top of the original stack / / return OK;} / / algorithm 4 fetch the top element of the chain stack Data GetTop (LinkStack S) {/ / return the top element of S without modifying the top pointer if (S! = NULL) / / stack non-empty return S-> data / / returns the value of the top element of the stack. The top pointer of the stack is unchanged} bool empty (LinkStack& S) {if (S = = NULL) return true; else return false;} / void empty (LinkStack& S) {/} # ifdef _ cplusplus} # endif/*int main () {LinkStack s; int choose, flag = 0; SElemType j, t; cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.