Advertisement
Guest User

Untitled

a guest
Feb 28th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include<locale>
  3. using namespace std;
  4.  
  5. int RecursivePow(int base, int power)
  6. {
  7. long long int pow=1;
  8. if (power==0)
  9. return pow;
  10. else
  11. return pow=pow*base*RecursivePow(base,power-1);
  12. }
  13. int Recursive(int base)
  14. {
  15. long long int fact=1;;
  16. if (base==0)
  17. fact=1;
  18. else
  19. fact=fact*base*Recursive(base-1);
  20. return fact;
  21. }
  22. int main()
  23. {
  24. setlocale(LC_ALL,"rus");
  25. int n;
  26. cout<<"Введите число"<<endl;
  27. while((!(cin >>n))||(n<0))
  28. {
  29. cout << "Вы ввели некорректные данные, попробуйте еще раз\n";
  30. cin.clear();
  31. cin.sync();
  32.  
  33. }
  34.  
  35. cout<<"a"<<n<<"="<< double(RecursivePow(3,n))/ double(Recursive(n))<<endl;
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement