aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzedarider <ymherklotz@gmail.com>2016-02-28 16:18:47 +0000
committerzedarider <ymherklotz@gmail.com>2016-02-28 16:18:47 +0000
commite7978d38642d83bfaea85f637cc594037ea5ca3a (patch)
treea1d7c163cce4f45709bcdff9122dc74063bb572e
parentce84354dfd61eedf80044209b88023fb0c46b70b (diff)
downloadimperial_2015-e7978d38642d83bfaea85f637cc594037ea5ca3a.tar.gz
imperial_2015-e7978d38642d83bfaea85f637cc594037ea5ca3a.zip
Changed the Recursion, finished
-rw-r--r--C++/Recursion.cpp21
1 files changed, 21 insertions, 0 deletions
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;
+}