[google面试题]Write a program to determine whether an input string x is a substring of another input string y.
(For example,"bat" is a substring of "abate",but not of "beat".) You may use any language you like. Sample Answer(inC++):bool has Substring(const char *str, constchar *find) { if(str == '\0' && find == '\0') return true; for(int i = 0; str != '\0'; i++) { boolfoundNonMatch = false; for(int j = 0; find != '\0'; j++) { if(str != find) { foundNonMatch = true; break; } } if(!foundNonMatch) return true; } return false;}
页:
[1]