C/C++ ±ÊÊÔ¡¢ÃæÊÔÌâÄ¿´ó»ã×Ü
1.ÇóÏÂÃ溯ÊýµÄ·µ»ØÖµ£¨ ΢Èí£©
int func(x)
{
int countx = 0;
while(x)
{
countx ++;
x = x&(x-1);
}
return countx;
}
¼Ù¶¨x = 9999¡£ ´ð°¸£º8
˼·£º½«xת»¯Îª2½øÖÆ£¬¿´º¬ÓеÄ1µÄ¸öÊý¡£
2. ʲôÊÇ“ÒýÓÔ£¿ÉêÃ÷ºÍʹÓÓÒýÓÔҪעÒâÄÄЩÎÊÌ⣿
´ð£ºÒýÓþÍÊÇij¸öÄ¿±ê±äÁ¿µÄ“±ðÃû”(alias)£¬¶ÔÓ¦ÓõIJÙ×÷Óë¶Ô±äÁ¿Ö±½Ó²Ù×÷Ч¹ûÍêÈ«Ïàͬ¡£ÉêÃ÷Ò»¸öÒýÓõÄʱºò£¬ÇмÇÒª¶ÔÆä½øÐгõʼ»¯¡£ÒýÓÃÉùÃ÷Íê±Ïºó£¬Ï൱ÓÚÄ¿±ê±äÁ¿ÃûÓÐÁ½¸öÃû³Æ£¬¼´¸ÃÄ¿±êÔÃû³ÆºÍÒýÓÃÃû£¬²»ÄÜÔٰѸÃÒýÓÃÃû×÷ΪÆäËû±äÁ¿ÃûµÄ±ðÃû¡£ÉùÃ÷Ò»¸öÒýÓ㬲»ÊÇж¨ÒåÁËÒ»¸ö±äÁ¿£¬ËüÖ»±íʾ¸ÃÒýÓÃÃûÊÇÄ¿±ê±äÁ¿ÃûµÄÒ»¸ö±ðÃû£¬Ëü±¾Éí²»ÊÇÒ»ÖÖÊý¾ÝÀàÐÍ£¬Òò´ËÒýÓñ¾Éí²»Õ¼´æ´¢µ¥Ôª£¬ÏµÍ³Ò²²»¸øÒýÓ÷ÖÅä´æ´¢µ¥Ôª¡£²»Äܽ¨Á¢Êý×éµÄÒýÓá£
3. ½«“ÒýÓÔ×÷Ϊº¯Êý²ÎÊýÓÐÄÄЩÌص㣿
£¨1£©´«µÝÒýÓøøº¯ÊýÓë´«µÝÖ¸ÕëµÄЧ¹ûÊÇÒ»ÑùµÄ¡£Õâʱ£¬±»µ÷º¯ÊýµÄÐβξͳÉΪÔÀ´Ö÷µ÷º¯ÊýÖеÄʵ²Î±äÁ¿»ò¶ÔÏóµÄÒ»¸ö±ðÃûÀ´Ê¹Óã¬ËùÒÔÔÚ±»µ÷º¯ÊýÖжÔÐβαäÁ¿µÄ²Ù×÷¾ÍÊǶÔÆäÏàÓ¦µÄÄ¿±ê¶ÔÏó£¨ÔÚÖ÷µ÷º¯ÊýÖУ©µÄ²Ù×÷¡£
£¨2£©Ê¹ÓÃÒýÓô«µÝº¯ÊýµÄ²ÎÊý£¬ÔÚÄÚ´æÖв¢Ã»ÓвúÉúʵ²ÎµÄ¸±±¾£¬ËüÊÇÖ±½Ó¶Ôʵ²Î²Ù×÷£»¶øʹÓÃÒ»°ã±äÁ¿´«µÝº¯ÊýµÄ²ÎÊý£¬µ±·¢Éúº¯Êýµ÷ÓÃʱ£¬ÐèÒª¸øÐβηÖÅä´æ´¢µ¥Ôª£¬ÐβαäÁ¿ÊÇʵ²Î±äÁ¿µÄ¸±±¾£»Èç¹û´«µÝµÄÊǶÔÏ󣬻¹½«µ÷Óÿ½±´¹¹Ô캯Êý¡£Òò´Ë£¬µ±²ÎÊý´«µÝµÄÊý¾Ý½Ï´óʱ£¬ÓÃÒýÓñÈÓÃÒ»°ã±äÁ¿´«µÝ²ÎÊýµÄЧÂʺÍËùÕ¼¿Õ¼ä¶¼ºÃ¡£
£¨3£©Ê¹ÓÃÖ¸Õë×÷Ϊº¯ÊýµÄ²ÎÊýËäȻҲÄÜ´ïµ½ÓëʹÓÃÒýÓõÄЧ¹û£¬µ«ÊÇ£¬ÔÚ±»µ÷º¯ÊýÖÐͬÑùÒª¸øÐβηÖÅä´æ´¢µ¥Ôª£¬ÇÒÐèÒªÖظ´Ê¹ÓÃ"*Ö¸Õë±äÁ¿Ãû"µÄÐÎʽ½øÐÐÔËË㣬ÕâºÜÈÝÒײúÉú´íÎóÇÒ³ÌÐòµÄÔĶÁÐԽϲÁíÒ»·½Ã棬ÔÚÖ÷µ÷º¯ÊýµÄµ÷Óõ㴦£¬±ØÐëÓñäÁ¿µÄµØÖ·×÷Ϊʵ²Î¡£¶øÒýÓøüÈÝÒ×ʹÓ㬸üÇåÎú¡£
4. ÔÚʲôʱºòÐèҪʹÓÓ³£ÒýÓÔ£¿¡¡
Èç¹û¼ÈÒªÀûÓÃÒýÓÃÌá¸ß³ÌÐòµÄЧÂÊ£¬ÓÖÒª±£»¤´«µÝ¸øº¯ÊýµÄÊý¾Ý²»ÔÚº¯ÊýÖб»¸Ä±ä£¬¾ÍӦʹÓó£ÒýÓᣳ£ÒýÓÃÉùÃ÷·½Ê½£ºconst ÀàÐͱêʶ·û &ÒýÓÃÃû=Ä¿±ê±äÁ¿Ãû£»
Àý1
int a ;
const int &ra=a;
ra=1; //´íÎó
a=1; //ÕýÈ·
Àý2
string
Ïà¹ØÎĵµ£º
C++ѧϰ±Ê¼Ç--Linuxϱà³Ì
Ò»¡¢¹ØÓÚBoostµÄʹÓ㬼¸ÖÖ³£Ó÷½·¨£¬Ö»ÊÇ×Ô¼º¹¤×÷¡¢Ñ§Ï°ÖÐ×ܽáµÄ£¬ÓÐЩ·½·¨µÄÈ·ÓÐЩ·±Ëö£¬ÄÜÂú×ãÐèÇó£¬Ó¦¸Ã»¹Óиü¼Ó¼òµ¥¿ì½ÝµÄ·½Ê½£¬´ý¸Ä½ø¡£
1¡¢ÅжÏ×Ö·û´®ÓëÕýÔò±í´ïʽÊÇ·ñÆ¥Å䣨ÍêÈ«Æ¥Å䣩
bool IsMatch(const char* data,const char * regx)
{
boost::regex express ......
ÈçºÎÖÕÖ¹Ï̵߳ÄÔËÐУ¨C/C++£©
ÏëÒªÖÕÖ¹Ï̵߳ÄÔËÐУ¬¿ÉÒÔʹÓÃÒÔÏ·½·¨£º
1¡¢Ï̺߳¯Êý·µ»Ø£¨×îºÃʹÓø÷½·¨£©¡£
2¡¢Í¨¹ýµ÷ÓÃExitThreadº¯Êý£¬Ï߳̽«×ÔÐг·Ïû£¨×îºÃ²»Ê¹Óø÷½·¨£©¡£
3¡¢Í¬Ò»¸ö½ø³Ì»òÁíÒ»¸ö½ø³ÌÖеÄÏ̵߳÷ÓÃTerminateThreadº¯Êý£¨Ó¦±ÜÃâʹÓø÷½·¨£©¡£
4¡¢ExitProcessºÍTerminateProcessº¯ÊýÒ²¿ÉÒÔÓÃÀ ......
JAVAºÍC++¶¼ÊÇÃæÏò¶ÔÏóÓïÑÔ¡£Ò²¾ÍÊÇ˵£¬ËüÃǶ¼Äܹ»ÊµÏÖÃæÏò¶ÔÏó˼Ï루·â×°£¬¼Ì³Ë£¬¶à̬£©¡£
C++Äܱ»²Ù×÷ϵͳ£¨Window£¬Linux£©Ö±½ÓÔËÐУ¬¶øJava²»ÐУ¬ÐèÒªÓиöJVM¡£
javaÓïÑÔ¸ø¿ª·¢ÈËÔ±ÌṩÁ˸üΪ¼ò½àµÄÓï·¨£»È¡ÏûÁËÖ¸Õë´øÀ´¸ü¸ßµÄ´úÂëÖÊÁ¿£»ÍêÈ«ÃæÏò¶ÔÏ󣬶ÀÌصÄÔËÐлúÖÆÊÇÆä¾ßÓÐÌìÈ»µÄ¿ÉÒÆÖ²ÐÔ¡£
1£®Ö¸Õë
JAVA ......
Óë &£º ÈκÎλÓÃ&ÔËËãÓë0½áºÏ½á¹ûΪ0£¬Óë1½áºÏ½á¹ûΪÆä±¾Éí£»
»ò | £º ÈκÎλÓÃ|ÔËËãÓë0½áºÏ½á¹ûΪÆä±¾Éí£¬Óë1½áºÏ½á¹ûΪ1£»
Òì»ò ^ £º ÈκÎλÓÃ^ÔËËãÓë0½áºÏ½á¹ûΪÆä±¾Éí£¬Óë1½áºÏÔòÈ¡·´£» ......