Last active
July 17, 2016 21:58
-
-
Save mormahr/0b9cf26ecc62b286743ec5643286fb9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
using namespace std; | |
int Ack(int n, int m) { | |
static int aufrufe = 0; | |
aufrufe++; | |
cout << "[" << setw(6) << aufrufe << ". Aufruf] " << "Ack(" << n << ", " << m << ")" << endl; | |
if (n == 0 && m >= 0) { | |
return m + 1; | |
} else if (n >= 1 && m == 0) { | |
return Ack(n - 1, 1); | |
} else if (n >= 1 && m >= 1) { | |
return Ack(n - 1, Ack(n, m - 1)); | |
} else { | |
throw "Nicht definiert"; | |
} | |
} | |
int main() { | |
cout << Ack(3, 4) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment