rengetsu

ProcedurProgramavimas_3.14

May 21st, 2018
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. using namespace std;
  4. ifstream fin("14.in");
  5. ofstream fout("14.txt");
  6. void recurse(long long int n, long long int as, long long int bs, long long int sums, long long int pras, long long int ys)
  7. {
  8.     if(ys!=n){
  9.         sums=bs+as;
  10.         pras=as;
  11.         as=bs;
  12.         bs=pras+bs;
  13.         ys++;
  14.         recurse(n, as, bs, sums, pras, ys);}
  15.     else{
  16.        ofstream fout("14.txt");
  17.        fout<<sums<<endl;}
  18. }
  19. int main()
  20. {
  21.     long long int s, a=0, b=1, sum=1, pra=1, y=1;
  22.     fin>>s;
  23.     if(s==0){fout<<"0"<<endl;}
  24.     else{recurse(s,a,b,sum,pra,y);}
  25.     return 0;
  26. }
Add Comment
Please, Sign In to add comment