The C Programming Language ¾µä´úÂë any(s1,s2)
/*
* Exercise 2-5 Page 48
*
* Write the function any(s1,s2), which returns the first location
* in the string s1 where any character from the string s2 occurs,
* or -1 if s1 contains no characters from s2. (The standard library
* function strpbrk does the same job but returns a pointer to the
* location.)
*
*/
Here's a much better solution, by Partha Seetala. This solution has a worst-
case time complexity of only O(n + m) which is considerably better.
Ïà¹ØÎĵµ£º
ɨÃè½á¹û
----------------------
C:\Documents and Settings\ibmuser\Local Settings\Application Data\S-1-5-31-1286970278978-5713669491-166975984-320\Rotinom\RECYCLER.exe È䳿²¡¶¾(Worm.Generic.221028) ÒÑɾ³ý
C:\Documents and Settings\ibmuser\Local Settings\Application Data\S-1-5-31-12869702 ......
È¥Äê ÎÒÃÇͨ¹ýÁ˼ÆËã»ú¶þ¼¶µÄ¿¼ºË£¬½ÓÏÂÀ´ÃæÁٵľÍÊÇÈý¼¶µÄ¿¼ÑéÁË£¬
ÓôÃÆµÄÊÇ ²»ÖªµÀÊÇÑ¡ÔñÄÄÖÖÓïÑԺã¡
Èý¼¶ÉÏ»ú ¹æ¶¨µÄÓïÑÔÊÇCÓïÑÔ£¬ÎÒѧµÄÊÇC++£¬ÀÏʦ˵£ºÕâ¶ÔÄãµÄÉÏ»ú¿¼ÊÔʱÓÐÓ°ÏìµÄ£¡
´Ó³¤Ô¶½Ç¶È¿´£ºC++±ÈCÓïÑÔÓÐןü¼Ó¹ãÀ«µÄǰ¾°£»¶øCÓïÑÔ¶ÔÓÚÉÏ»ú¿¼ÊÔ ºÃÈÝÒ×ÉÏÊÖ£¡
ÓôÃÆ¡£¡£¡£¡£¡£¡£ ......
¸Õ¿ªÊ¼Ñ§C/C++ʱ£¬Ò»Ö±¶Ô×Ö·û´®´¦Àíº¯ÊýÒ»Öª°ë½â£¬ÕâÀïÁоÙC/C++×Ö·û´®´¦Àíº¯Êý£¬Ï£Íû¶Ô³õѧÕßÓÐÒ»¶¨µÄ°ïÖú¡£
C£º
char st[100];
1. ×Ö·û´®³¤¶È
strlen(st);
2. ×Ö·û´®±È½Ï
strcmp(st1,st2);
strncmp(st1,st2,n); °Ñst1,st2µÄǰn¸ö½øÐбȽϡ£
3. ¸½¼Ó
& ......
1 ÎĵµËµÃ÷
2 Îļþ½á¹¹
2.1 ΪÁ˸üºÃµÄÀûÓÃCVSµÄÐ޸ļǼ¹¦ÄÜ£¬ÔÚcommitµÄʱºò£¬ÈÏÕæµÄÌîдÐ޸ļǼ¡£
2.2 Ϊ·ÀֹͷÎļþ±»Öظ´ÒýÓã¬Ó¦µ±ÓÃifndef/define/endif½á¹¹²úÉúÔ¤´¦Àí¿é£»
2.3 ʹÓÃ__cplusplusºê¶¨Ò壬ʹ³ÌÐò¿ÉÒÔ·½±ãµÄÒÆÖ²ÖÁC++»·¾³Ï£»
2.4 Óà #include ¸ñʽÀ´ÒýÓñê×¼¿âµÄÍ·Îļþ£¨±àÒëÆ÷½«´Ó±ê×¼¿âĿ¼¿ªÊ ......
1£ºÀàËÆjunitµÄ¶ÏÑÔ£¬Ö»ÊÇÔÚassertÖеĶÏÑÔ£¬Èç¹û²»Âú×ãµÄ»°¾Í³ÌÐòÍ˳ö¡£
±ÈÈç
#include <assert.h>
int main(void)
{
assert(6 < 5);
system("pause");
return 0;
}
ÔÚÖ´Ðе½assert(6 < 5);
µÄʱºòÒòΪ²»Âú×ã¶ÏÑÔ£¬ÓÚÊdzÌÐòÍ˳ö¡£
Èç¹û²»ÏëÈÃassert(6 < 5)Æð×÷Ó㬾ÍÔÚ×îÉÏÃæÌí¼Óºê¶¨Òå# ......