Created
January 12, 2015 09:51
-
-
Save jmcph4/8071da525ebb695d111a to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
| unsigned int A(unsigned int m, unsigned int n) | |
| { | |
| // std::cout << "A(" << m << "," << n << ")" << std::endl; | |
| if(m == 0) | |
| { | |
| return n + 1; | |
| } | |
| else | |
| { | |
| if(n == 0) | |
| { | |
| return A(m - 1, 1); | |
| } | |
| else | |
| { | |
| return A(m - 1, A(m, n - 1)); | |
| } | |
| } | |
| } | |
| int main(int argc, char** argv) | |
| { | |
| if(argc == 3) | |
| { | |
| unsigned int m = atoi(argv[1]); | |
| unsigned int n = atoi(argv[2]); | |
| std::cout << A(m, n) << std::endl; | |
| return 0; | |
| } | |
| else | |
| { | |
| std::cerr << argv[0] << " m n" << std::endl << "where m and n are non-negative integers" << std::endl; | |
| return 1; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment