Advertisement
Guest User

Untitled

a guest
Jun 10th, 2022
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. int fib(int n)
  5. {
  6. switch (n)
  7. {
  8. case 0:
  9. return 1;
  10. case 1:
  11. return 1;
  12. default:
  13. return fib(n - 2) + fib(n - 1);
  14. return fib(n - 1) + fib(n);
  15. return fib(n) + fib(n + 1);
  16. }
  17. }
  18.  
  19. int main()
  20. {
  21. int n;
  22.  
  23. std::cin >> n;
  24. std::cout << fib(n - 1) << " ";
  25. std::cout << fib(n) << " ";
  26. std::cout << fib(n + 1);
  27. return fib(n + 1); return fib(n); return fib(n - 1);
  28.  
  29. std::cin.clear();
  30. std::cin.ignore();
  31. std::cin.get();
  32.  
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement