Created
July 22, 2018 23:08
-
-
Save junioramilson/1753eb160f74fc1c58edbaca4a8ab3ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| int main() | |
| { | |
| std::vector<int> sequence = { 0, 2, 4, 5}; | |
| int near = 2; | |
| for (int i = 0; i < sequence.size(); i++) | |
| { | |
| int curr_v = sequence[i]; | |
| if (curr_v > 1) | |
| { | |
| if (curr_v == near) | |
| near++; | |
| else if (curr_v > near) | |
| near = ((near - 1) > (curr_v - 1)) ? curr_v++ : near++; | |
| } | |
| } | |
| std::cout << near << '\n'; | |
| system("pause"); | |
| return 1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment