rengetsu

ProcedurProgramavimas_3.11

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