fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. string st1, subst1, message=" ";
  6. bool found=false;
  7. cout<<"Enter string and subst:";
  8. cin>>st1 >>subst1;
  9.  
  10. for (int a=0; !found && a<st1.length();a++) {
  11. if (st1[a]==subst1[0]) {
  12. found = true; // there's some hope
  13. for (int k=0; found && k<subst1.length(); k++) {
  14. if (a+k>=st1.length() || st1[a+k]!=subst1[k])
  15. found = false;
  16. }
  17. }
  18. }
  19. message = found ? "True":"False";
  20. cout<< message<<endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 3460KB
stdin
alice cep
stdout
Enter string and subst:False