²éÕÒ×Ö·û´®ÖÐ×Ö·û²»Öظ´µÄ×î´ó×Ó´®(C/C++)
//ÊäÈë²ÎÊý£º*str ËÑË÷×Ö·û´®
// subStrLen ÓÃÓÚ·µ»ØÕÒµ½µÄ×î´ó×Ó×Ö·û´®³¤¶È
//·µ»Ø£ºÕÒµ½µÄ×î´ó×Ó×Ö·û´®Ö¸Õë
char * findMaxSubStr(char *str, int &subStrLen){
char *subStr;
char *p = str;
int index[256] ;
for (int ix = 0; ix < sizeof(index)/sizeof(index[0]); ix++)
{
index[ix] = -1;
}
int subStrPos = 0; // ×Ó×Ö·û´®ÔÚ×Ö·û´®strÖеÄÆ«ÒÆ
int charPos = 0; // µ±Ç°×Ö·ûÔÚ×Ö·û´®strÖеÄÆ«ÒÆ
int currLen = 0; //µ±Ç°×Ó×Ö·û´®³¤¶È
int maxLen = 0; //ÒѾÕÒµ½µÄ×î´ó×Ó×Ö·û´®³¤¶È
char ch;
while (ch = *p)
{
if (index[ch] < subStrPos){ //×Ö·ûÊ״γöÏÖ »òÕß ×Ö·ûÔÚ×Ó×Ö·û´®¿ªÊ¼µÄλÖúóÊ״γöÏÖ
index[ch] = charPos;
currLen++;
}else {
currLen = charPos - index[ch];
subStrPos = ++index[ch];
index[ch] = charPos;
}
if (currLen > maxLen)
{
subStr = str + subStrPos;
maxLen = currLen;
}
p++;
charPos++;
}
subStrLen = maxLen;
return subStr;
}
Ïà¹ØÎĵµ£º
Ô´³ÌÐò±àÒë
MakefileµÄ±àд
³ÌÐò¿âµÄÁ´½Ó
³ÌÐòµÄµ÷ÊÔ
Í·ÎļþºÍϵͳÇóÖú
1.Ô´³ÌÐòµÄ±àÒë
ÔÚLinuxÏÂÃæ,Èç¹ûÒª±àÒëÒ»¸öCÓïÑÔÔ´³ÌÐò,ÎÒÃÇҪʹÓÃGNUµÄgcc±àÒëÆ÷. ÏÂÃæÎÒÃÇÒÔÒ»¸öʵÀýÀ´ËµÃ÷ÈçºÎʹÓÃgcc±àÒëÆ÷.
......
ÒÔ i2c-mpc.c Çý¶¯Ä£¿éΪÀý
fsl_i2c_init -> of_register_platform_driver -> of_register_driver -> driver_register -> bus_add_driver -> driver_attach
-> bus_for_each_dev -> __driver_attach -> driver_probe_device -> really_probe -> drv->probe(dev); ......
¡¡¡¡Ëã·¨£¨Algorithm£©£º¼ÆËã»ú½âÌâµÄ»ù±¾Ë¼Ïë·½·¨ºÍ²½Öè¡£Ëã·¨µÄÃèÊö£ºÊǶÔÒª½â¾öÒ»¸öÎÊÌâ»òÒªÍê³ÉÒ»ÏîÈÎÎñËù²ÉÈ¡µÄ·½·¨ºÍ²½ÖèµÄÃèÊö£¬°üÀ¨ÐèҪʲôÊý¾Ý£¨ÊäÈëʲôÊý¾Ý¡¢Êä³öʲô½á¹û£©¡¢²ÉÓÃʲô½á¹¹¡¢Ê¹ÓÃʲôÓï¾äÒÔ¼°ÈçºÎ°²ÅÅÕâЩÓï¾äµÈ¡£Í¨³£Ê¹ÓÃ×ÔÈ»ÓïÑÔ¡¢½á¹¹»¯Á÷³Ìͼ¡¢Î±´úÂëµÈÀ´ÃèÊöËã·¨¡£
¡¡¡¡Ò»¡¢¼ÆÊý¡¢ÇóºÍ¡ ......
±ê×¼ C I/O
º¯ÊýÁÐ±í£º
clearerr() Çå³ý´íÎó
fclose() ¹Ø±ÕÒ»¸öÎļþ
feof() Èç¹ûµ½´ïÎļþβ(end-of-file)·µ»Ø"True"(Õæ)
ferror() ¼ì²éÒ»¸öÎļþ´íÎó
fflush() ÊéдÊä³ö»º´æµÄÄÚÈÝ
fgetc() ´ÓÁ÷»ñÈ¡Ò»¸ö×Ö·û
fgetpos() »ñÈ¡ÎļþλÖÃÖ¸Õë
fgets() ´ÓÒ»¸öÁ÷»ñÈ¡Ò»´®×Ö·û
fopen() ´ò¿ªÒ»¸öÎļþ ......