rengetsu

ProcedurProgramavimas_3.13

May 21st, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7. long long n, g=1, l=2, h=1;
  8.  
  9. ifstream fin("13.txt");
  10. ofstream fot("13.out");
  11.  
  12. int rekursine()
  13. {
  14.     if(n%2==0 && l<=n)
  15.     {
  16.         g=g*l;
  17.         l=l+2;
  18.         rekursine();
  19.     }
  20.     if(n%2!=0 && h<=n)
  21.     {
  22.          g*=h;
  23.          h+=2;
  24.          rekursine();
  25.     }
  26.     else
  27.     {
  28.         return g;
  29.     }
  30. }
  31.  
  32. int main()
  33. {
  34.     fin >> n;
  35.     rekursine();
  36.     fot << g;
  37.     return 0;
  38. }
Add Comment
Please, Sign In to add comment