From 53b9d47f3c9be0bb352b504e5684cceb7421ae39 Mon Sep 17 00:00:00 2001 From: nvhaizi1 Date: Wed, 18 May 2022 17:26:40 +0800 Subject: [PATCH] =?UTF-8?q?FindNode=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rail.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/rail.c b/src/rail.c index bd21bb6..bd8d8a1 100644 --- a/src/rail.c +++ b/src/rail.c @@ -39,4 +39,27 @@ rail_node_t *CreateRails(int length, int node_num) head->last_node = node; return head; -} \ No newline at end of file +} + +rail_node_t *FindNode(rail_node_t *rails, int id) +{ + rail_node_t *p = NULL; + if(rails) + { + if(rails->id == id) + { + return rails; + } + if(rails->next_node != NULL) + { + p = FindNode(rails->next_node, id); + if(p) + { + return p; + } + } + + } + return NULL; +} +