From e7978d38642d83bfaea85f637cc594037ea5ca3a Mon Sep 17 00:00:00 2001 From: zedarider Date: Sun, 28 Feb 2016 16:18:47 +0000 Subject: Changed the Recursion, finished --- C++/Recursion.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/C++/Recursion.cpp b/C++/Recursion.cpp index 97f772b..cd60f0a 100644 --- a/C++/Recursion.cpp +++ b/C++/Recursion.cpp @@ -99,3 +99,24 @@ void deallocateList(linkNode* &hdList) { delete tmpNode; } } + +int countEqual(linkNode* hdList, list_t el) { + int count = 0; + while(hdList != NULL) { + if(hdList->element == el) { + ++count; + } + hdList = hdList->next; + } + return count; +} + +int countEqualRec(linkNode* hdList, list_t el, int count) { + if(hdList != NULL) { + if(hdList->element == el) { + ++count; + } + countEqualRec(hdList->next, el, count); + } + return count; +} -- cgit