tuttelikz

#147 - Числа Фибоначчи [+]

Sep 24th, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  //   freopen("input.txt, "r", stdin);
  9.  //   freopen("output.txt, "r", stdout);
  10.     int N;
  11.     int a[50];
  12.     a[0] = 0;
  13.     a[1] = 1;
  14.     cin>>N;
  15.     for (int i = 2; i<=N; i++) {
  16.         a[i] = a[i-1] + a[i-2];
  17.     }
  18.     cout<<a[N];
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment