fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int i,j,l;
  6. char str[]="my name is aditya";
  7. char str2[]="aditya";
  8. for( l=0; str2[l]!=NULL; l++);
  9. for(i=0,j=0 ; str[i]!=NULL && str2[j]!=NULL;)
  10. {
  11. if(str2[j]==str[i])
  12. {
  13. i++;
  14. j++;
  15. }
  16. else
  17. j=0;
  18. }
  19. if(l==j)
  20. cout<<"sub string"<<endl;
  21. return 0;
  22. }
Time limit exceeded #stdin #stdout 5s 3336KB
stdin
Standard input is empty
stdout
Standard output is empty