SHARE
TWEET

Untitled

a guest Oct 9th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4.     int x, n;
  5.     int z;
  6.     int wew;
  7.     long long int tab[20];
  8.     tab[0] = 0;
  9.     tab[1] = 1;
  10.     tab[2] = 1;
  11.     for (int i = 3; i < 20; i++)
  12.     {
  13.         tab[i] = tab[i - 1] + tab[i - 2];
  14.     }
  15.     cin >> n;
  16.     bool t = true;
  17.     x = 0;
  18.     while (t) {
  19.         n++;
  20.         cout << " n: " << n << endl;
  21.         z = 1;
  22.         while (x < n) {
  23.             z++;
  24.             x = tab[z];
  25.  
  26.         }
  27.         z--;
  28.         x = tab[z];
  29.         if (n > 100) {
  30.             break;
  31.         }
  32.         cout << "Pierwszy x: " << x << endl;
  33.         //indeks pierwszej mniejsze
  34.  
  35.  
  36.     }
  37.     for (int zew = z; zew >= 0; zew--) {
  38.         int sum = 0;
  39.         for (wew = zew; wew >= 0; wew--) {
  40.             sum += tab[wew];
  41.             if (sum == n)
  42.                 break;
  43.             if (sum > n) {
  44.                 break;
  45.             }
  46.            
  47.         }
  48.         if (sum == n)
  49.             break;
  50.         if (sum < n && wew == 0) {
  51.             t = false;
  52.         }
  53.     }
  54.     cout << n << endl;
  55.     return 0;
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top