¡¾ÌâÄ¿4¡¿ÈçºÎ×Ô¼ºÊµÏÖCº¯Êýstrstr()
½âÌâ˼·£º Õâ¸öÍøÂçÉÏÒѾÓкܶà´ð°¸£¬ÕâÀï
ÁоÙÒ»¸ö¸´ÔÓ¶ÈΪ0(m*n)µÄÀý×Ó¡£ÊµÏÖµÄÔÀí
ºÜ¼òµ¥£¬Ë³Ðò±éÀúÒª²éÕÒµÄ×Ö·û´®£¬Èç¹ûûÓÐÕÒ
µ½£¬×Ö·û´®Ö¸ÕëÍùǰһ룬ÔÙÍùºó±È½ÏÒª²éÕÒµÄ
×Ö·û´®£¨Ä£Ê½´®£©£¬ÈçÏÂͼËùʾ£º
a b c d d d a d a c a b d a d d d a d c k
->
d a d a
char* strstr(const char* s1, const char* s2)
{
if(s1 == NULL || s2 == NULL)
return NULL;
while(*s1)
{
while(1)
{
int i = 0;
if(s2[i] == NULL)
return (char*)s1;
if(s2[i] != s1[i])
break;
i++;
}
s1++;
}
return NULL;
}
Ïà¹ØÎĵµ£º
×Ô¼ºÐ´µÄC/C++±àÒëÆ÷Doctors[Èí¼þ+Îĵµ]
http://blog.csdn.net/huyansoft/archive/2009/08/20/4464772.aspx
¸üа汾1.0.1£º¸Ã°æ±¾½â¾öÁË֮ǰ1.0.0°æ±¾ÖÐÕÒ²»µ½Á´½Ó¿âlibc.libµÄÎÊÌ⣬ÒÔ¼°IDEϵã»÷Project²Ëµ¥³öÏÖµÄBUG¡£ÏÂÔØµØÖ·£ºhttp://download.csdn.net/source/1597132
Doctors±àÒëÆ÷ÄÚ²¿ÊµÏÖ
For version 1.0.1 ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using  ......
ת×Ô£ºhttp://dev.csdn.net/article/29/29329.shtm
¹ØÓÚÂß¼ÒÆÎ»¡¢ËãÊõÒÆÎ»¿É²Î¼û ѸÀ×Éî´ó±ÊÊÔÌⲿ·Ö¡£µÄÒ»µÀÌâ¡£
ÒÔǰ¿´µ½C++±ê×¼ÉÏ˵£¬ÒÆÎ»ÔËËã·û£¨<<¡¢>>£©³ö½çʱµÄÐÐΪ²¢²»È·¶¨£º
The behavior is undefined if the right operand is negative, or greater than or equal to the length in bit ......
ÏÖÔڵĹ«Ë¾ÕÐÆ¸,¶¼Òª±ÊÊÔÃæÊÔ.Èç¹ûÄã²»ÊÇÄÇÖÖ±à³Ì¹¦µ×·Ç³£ÉîºñµÄÈË,ÓÖ²»ºÃºÃ×¼±¸Ò»·¬,ÔÚ±ÊÊÔÃæÊÔÖÐÍùÍù»á´¦ÓÚ±»¶¯¾ÖÃæ.ËäÈ»ÓÐЩ±ÊÊÔÌâÊǹÊÒâΪÄÑÎÒÃÇ£¬Óеã×êÅ£½Ç¼â.µ«ÊǺܶà±ÊÊÔÌâÃæÊÔÌâȷʵÄܹ»ºÜºÃµØ¿´³öÎÒÃǵĻù´¡. ÔÚÕâÀï,ÎÒ¾ÍÂÔÈ¥ÄÇЩ×êÅ£½Ç¼âµÄÌâ.´ÓcsdnÂÛ̳ÎÒ½ü°ëÄêµÄÊÕ¼¯ÖÐÑ¡³ö10µÀÓдú±íÐÔµÄÌâÄ¿,ÄѶȻù±¾ÉÏÊÇÖ ......