MeehoweCK

Untitled

Oct 11th, 2020
814
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. //mateusz Lesniczak pocztowka
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. bool czy_jest(int start, int koniec, vector<int> numery)
  8. {
  9.     int n = numery.size();      // numery.size() - zwraca ile jest elementów w wektorze
  10.  
  11.     for(int i = 0; i < n; ++i)
  12.         if(numery[i] >= start && numery[i] <= koniec)
  13.             return true;
  14.     return false;
  15. }
  16.  
  17. int main()
  18. {
  19.     int n, m, liczba, sukcesy = 0;
  20.  
  21.     cin >> n >> m;
  22.  
  23.     vector<int> numery;
  24.  
  25.     for(int i = 0; i < n; ++i)
  26.     {
  27.         cin >> liczba;
  28.         if(liczba >= m)
  29.             numery.push_back(i);        // dodanie elementu na koniec tablicy
  30.     }
  31.  
  32.     for(int l = 0; l < n; ++l)
  33.         for(int p = 0; l + p < n; ++p)
  34.         {
  35.             if(czy_jest(l, n - 1 - p, numery))
  36.                 ++sukcesy;
  37.             else
  38.                 break;
  39.         }
  40.  
  41.     cout << sukcesy;
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment