Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- bool Oscilatoran(std::vector<double> v)
- {
- for (unsigned int i(1); i < v.size()-1; i++)
- {
- if((v.at(i) > v.at(i+1) && v.at(i) < v.at(i-1)) || (v.at(i) < v.at(i+1) && v.at(i) > v.at(i-1)))
- return false;
- }
- return true;
- }
- int main()
- {
- std::vector<double> v1{3, 7, 4, 6, 1, 5, 2, 3};
- std::vector<double> v2{3, 1, 5, 4, 7, 2, 3, 2};
- std::cout << Oscilatoran(v1) << std::endl << Oscilatoran(v2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement