Advertisement
Laitofai

BH | Разветвляющиеся алгоритмы

Dec 18th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     float prev=1, current=1, next=2, summa=0, m;
  8.     cin>>m;
  9.     summa+=prev;
  10.     while(current<=m){
  11.         summa+=current;
  12.         prev=current;
  13.         current=next;
  14.         next=prev+current;
  15.     }
  16.     cout<<summa;
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement