Advertisement
MeehoweCK

Untitled

Aug 19th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. bool f(vector<int> v)
  7. {
  8.     bool rosnacy = true;
  9.     bool malejacy = true;
  10.  
  11.     for(unsigned i = 1; i < v.size(); ++i)
  12.     {
  13.         if(v[i] < v[i - 1])
  14.             rosnacy = false;
  15.         if(v[i] > v[i - 1])
  16.             malejacy = false;
  17.         if(!rosnacy && !malejacy)
  18.             return false;
  19.     }
  20.     return true;
  21. }
  22.  
  23. int main()
  24. {
  25.     vector<int> wektor;
  26.     wektor.resize(10);
  27.     for(int i = 0; i < 10; ++i)
  28.         wektor[i] = (i-5)*(i-5);
  29.     cout << f(wektor) << endl;
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement