Implement strStr().
Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.
思路:这是一道字符串匹配的函数,就是找出needle在haystack首次出现的位置。暴力解决,简单明了。
class Solution { public: char *strStr(char *haystack, char *needle) { int hay_len=strlen(haystack); int nee_len=strlen(needle); for(int i=0;i<=hay_len-nee_len;i++) { char *str=haystack+i; char *sub_str=needle; while(*sub_str!='