Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- int termen_fibbo(int n);//term < sau = cu n
- int main()
- {
- ifstream fin("numere.in");
- ofstream fout("numere.out");
- int n,s=0,t;
- fin>>n;
- while(n>0)
- {
- t=termen_fibbo(n);
- if(t<=n)
- {
- fout<<t<<" ";
- n=n-t;
- }
- }
- fin.close();
- fout.close();
- return 0;
- }
- int termen_fibbo(int n)
- {
- int t1=1,t2=1,t3;
- while(t2<=n)
- {
- t3=t1+t2;
- t1=t2;
- t2=t3;
- }
- if(t2>n)
- return t1;
- else
- return t2;
- return 0;
- }
Add Comment
Please, Sign In to add comment