SHARE
TWEET

Untitled

a guest Feb 23rd, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int A(int m, int n) {
  6.     if (m == 0) return n + 1;
  7.     else if (n == 0) return A(m - 1, 1);
  8.     else return A(m - 1, A(m, n - 1));
  9. }
  10.  
  11. int just_A(int m, int n)
  12. {
  13.     if (m == 0) return n + 1;
  14.     else if (m == 1) return n + 2;
  15.     else if (m == 2) return 2 * n + 3;
  16.     else return pow(2, n + 3) - 3;
  17. }
  18.  
  19.  
  20. int main() {
  21.     int m, n;
  22.   cout << "Введите неотрицательные целые m и n: ";
  23.     cin >> m >> n;
  24.     if (m < 0 || n < 0) cout << "m и n должны быть неотрицательными";
  25.     else cout << "Значение функции Аккермана (не рекурсивно): " << just_A(m, n)
  26.     << "\nЗначение функции Аккермана (рекурсивно): " << A(m, n);
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top