Playground
#include <iostream> #include <string> using namespace std; bool contains(string large, string small) { for(int i=0; i + small.size() <= large.size(); i++) { bool allMatched = true; for(int j=0; j < small.size(); j++) { if(small[j] != large[i + j]) { allMatched = false; break; } } if(allMatched == true) { //go pronajdovme vo large, istiot pocnuva od pozicija i return true; } } return false; } int main() { string large, small; cin >> large >> small; cout << contains(large, small) << endl; return 0; }
Input data
Program output
abcabcde cab
Execute
Language: ????????? | Memory: ???? KB | Time: ??? ms
Nothing has been executed, yet!