In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Today we continue to learn about recursion. Let's first review the process of function calls: after the program runs, there is a special memory area for function calls. So what's the use of this memory area? 1, used to save the arguments in the function, local variables, temporary variables, etc.; 2, from the starting address to grow in one direction (such as: high address-> low address); 3, there is a dedicated "pointer" to identify the "top" of the currently used memory.
Then the stack area in the program is a special special memory area. As shown in the following figure
Let's take a look at an example: printing even nodes in a single linked list in reverse order. As shown below
Let's take a look at how the specific source code is implemented, as follows
# include # include # include "DTString.h" # include "LinkList.h" using namespace std;using namespace DTLib;struct Node {int value; Node* next;}; Node* create_list (int v, int len) {Node* ret = NULL; Node* slider = NULL; for (int iodized 0; ivalue = vested cargo; n-> next = NULL; if (slider = = NULL) {slider = n; ret = n } else {slider- > next = n; slider = n;} return ret;} void destory_list (Node* list) {while (list) {Node* del = list; list = list- > next; delete del;}} void print_list (Node* list) {while (list) {cout value next } cout value% 2) = = 0) {cout value 8, go to step 3
-- end: line 8 has room for the queen.
Let's take a look at the specific source code implementation, as follows
# include # include # include "DTString.h" # include "LinkList.h" using namespace std;using namespace DTLib;template
< int SIZE >Class QueueSolution: public Object {protected: enum {N = SIZE + 2}; struct Pos: public Object {Pos (int px = 0, int py = 0): X (px), y (py) {} int x; int y;}; int mchessboard [N] [N]; Pos m_direction [3]; LinkList solution; int m_count Void init () {m_count = 0; for (int iTuno; I)
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.