Skip to content

Instantly share code, notes, and snippets.

@xkrsz
Created March 22, 2017 10:17
Show Gist options
  • Save xkrsz/6680c5b44ee2deca17e4dc790a577bb6 to your computer and use it in GitHub Desktop.
Save xkrsz/6680c5b44ee2deca17e4dc790a577bb6 to your computer and use it in GitHub Desktop.
#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