Norbysweg

f75

Sep 29th, 2020
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void beolv(int &n)
  6. {
  7. cin>>n;
  8. }
  9. void fib(int n)
  10. {
  11. int f1=0,f2=1,i;
  12. if (n<1)
  13. return;
  14. for (i=0;i<n;i++)
  15. {
  16. cout<<f2<<" ";
  17. f2=f2+f1;
  18. f1=f2-f1;
  19. }
  20. }
  21. int main()
  22. {
  23. int n;
  24. beolv(n);
  25. fib(n);
  26. return 0;
  27. }
  28.  
Add Comment
Please, Sign In to add comment