Commit 9ce2d848 by Tobias.Allrich

### Added examples for recursion (9-1.cpp - 9-4.cpp)

parent 74eb6496
GI/Inf1/9-1.cpp 0 → 100644
 #include using namespace std; int steine(int h) { if(h < 1) return 0; if(h == 1) return 1; return steine(h-1) + h; } int main() { int hoehe = 0; cout<<"Bitte Hoehe eingeben: "; cin>>hoehe; cout<<"Es werden "<
GI/Inf1/9-2.cpp 0 → 100644
 #include using namespace std; int fak(int f) { if(f == 1) return 1; return fak(f - 1) * f; } int main() { int zahl; cout<<"Bitte Zahl eingeben: "; cin>>zahl; cout<
GI/Inf1/9-3.cpp 0 → 100644
 #include using namespace std; int ack(int m, int n) { if(m == 0) return n+1; if(n == 0 && m > 0) return ack(m - 1, 1); return ack(m - 1, ack(m, n - 1)); } int main() { cout<<"Ackermann-Funktion für m = 3, n = 14: "<
GI/Inf1/9-4.cpp 0 → 100644
 #include using namespace std; int bino(int n, int k) { if(n == k || k == 0) return 1; return bino(n-1, k) + bino(n - 1, k - 1); } int main() { int n, k; cout<<"Geben Sie n und k ein:\n"; cin>>n>>k; cout<<"Bino(n,k) = "<
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!