Guest User

Untitled

a guest
May 27th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. int termen_fibbo(int n);//term < sau = cu n
  5. int main()
  6. {
  7. ifstream fin("numere.in");
  8. ofstream fout("numere.out");
  9. int n,s=0,t;
  10. fin>>n;
  11. while(n>0)
  12. {
  13. t=termen_fibbo(n);
  14. if(t<=n)
  15. {
  16. fout<<t<<" ";
  17.  
  18. n=n-t;
  19. }
  20. }
  21. fin.close();
  22. fout.close();
  23. return 0;
  24. }
  25. int termen_fibbo(int n)
  26. {
  27. int t1=1,t2=1,t3;
  28. while(t2<=n)
  29. {
  30. t3=t1+t2;
  31. t1=t2;
  32. t2=t3;
  33. }
  34. if(t2>n)
  35. return t1;
  36. else
  37. return t2;
  38. return 0;
  39. }
Add Comment
Please, Sign In to add comment