Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. using namespace std;
  4. #define RESULT(n, m) do{ cout << "n= " << (n) << " m= " << (m) << endl; _getch();}while(false);
  5. int Akker(int n, int m) {
  6. if (m == 0) {
  7. RESULT(n, m);
  8. return n + 1;
  9. }
  10. if (m > 0 && n == 0) {
  11. RESULT(n, m);
  12. return Akker(m - 1, 1);
  13. }
  14. if (m > 0 && n > 0) {
  15. RESULT(n, m);
  16. return Akker(m - 1, Akker(m, n - 1));
  17. }
  18. }
  19. int main() {
  20. setlocale(0, "");
  21. int n, m;
  22. cout << "Введите число n и m: ";
  23. cin >> n >> m;
  24. cout << "Результат - " << Akker(n, m);
  25. system("pause");
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement