Last active
August 29, 2015 13:57
-
-
Save AlexTalker/9765813 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 <string> | |
| #include <iostream> | |
| int last_position = 0; | |
| std::string string = "abcdefghijklmnoprstuvwxyz"; | |
| std::string match = "jn"; | |
| std::string result; | |
| bool end_of_parsing = false; | |
| std::string next(){ | |
| bool end_of_word = false; | |
| std::string str = ""; | |
| if(last_position == string.length()){ | |
| end_of_parsing = true; | |
| } | |
| else{ | |
| bool eqi = false; | |
| for(unsigned int i = last_position;i < string.length();i++){ | |
| for(unsigned int j = 0;j < match.length();j++){ | |
| if(string[i] == match[j]){ | |
| if(!end_of_word){ | |
| end_of_word = true; | |
| } | |
| else{ | |
| eqi = true; | |
| } | |
| } | |
| if(j == (match.length()-1) && !eqi){ | |
| break; | |
| } | |
| } | |
| if(end_of_word && !eqi){ | |
| break; | |
| } | |
| if(!end_of_word) | |
| str += string[i]; | |
| last_position = i; | |
| } | |
| last_position++; | |
| } | |
| return str; | |
| } | |
| int main(void){ | |
| do{ | |
| std::cout << next() << std::endl; | |
| }while(!end_of_parsing); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment