Created
March 22, 2017 10:17
-
-
Save xkrsz/6680c5b44ee2deca17e4dc790a577bb6 to your computer and use it in GitHub Desktop.
This file contains 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> | |
bool checkIndex(std::string full, std::string part, int i, int j) { | |
printf("%c", full[i]); | |
if (part.length() <= j + 1) { | |
return true; | |
} | |
if (full.length() <= i + 1) { | |
return false; | |
} | |
if (full[i] == part[j]) { | |
checkIndex(full, part, ++i, ++j); | |
} | |
else { | |
checkIndex(full, part, ++i, j); | |
} | |
return false; | |
} | |
int main() { | |
if (checkIndex("lokomotywa", "omot", 0, 0)) { | |
printf("ok"); | |
} else { | |
printf("nook"); | |
} | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment