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
Ïà¹ØÎĵµ£º
#(¶Á×ö "C sharp")ÊÇ΢Èí¹«Ë¾ÔÚÈ¥ÄêÁùÔ·¢²¼µÄÒ»ÖÖеıà³ÌÓïÑÔ,²¢¶¨ÓÚÔÚ΢ÈíÖ°Òµ¿ª·¢ÕßÂÛ̳(PDC)ÉϵÇ̨ÁÁÏà.C#ÊÇ΢Èí¹«Ë¾Ñо¿Ô±Anders HejlsbergµÄ×îгɹû.C#¿´ÆðÀ´ÓëJavaÓÐמªÈ˵ÄÏàËÆ;Ëü°üÀ¨ÁËÖîÈçµ¥Ò»¼Ì³Ð,½çÃæ,ÓëJava¼¸ºõͬÑùµÄÓï·¨,ºÍ±àÒë³ÉÖмä´úÂëÔÙÔËÐеĹý³Ì.µ«ÊÇC#ÓëJavaÓÐ×ÅÃ÷ÏԵIJ»Í¬,Ëü½è¼øÁËDelphiµÄÒ»¸ ......
Python
µÄ
C/C++
À©Õ¹
By phidoit@gmail.com
¿ÉÀ©Õ¹ÐÔÊÇ
Python
µÄÒ»´óÌØÉ«£¬Ò»·½Ã棬ÓÉÓÚ
Python
ÊǽâÊÍÖ´Ðеģ¬Õâµ¼ÖÂÔËÐÐËÙ ......
C++Àà¿â½éÉÜ
ÔÙ´ÎÌåÏÖÁËC++±£³ÖºËÐÄÓïÑÔµÄЧÂÊͬʱ´óÁ¦·¢Õ¹Ó¦ÓÿâµÄ·¢Õ¹Ç÷ÊÆ!!ÔÚC++ÖУ¬¿âµÄµØλÊǷdz£¸ßµÄ¡£C++Ö®¸¸ Bjarne
StroustrupÏÈÉú¶à´Î±íʾÁËÉè¼Æ¿âÀ´À©³ä¹¦ÄÜÒªºÃ¹ýÉè¼Æ¸ü¶àµÄÓï·¨µÄÑÔÂÛ¡£ÏÖʵÖУ¬C++µÄ¿âÃÅÀà·±¶à£¬½â¾öµÄÎÊÌâÒ²ÊǼ«Æä¹ã·º£¬¿â´ÓÇáÁ¿¼¶µ½ÖØ
Á¿¼¶µÄ¶¼Ó ......
¹ØÓÚC++ºÍPythonÖ®¼ä»¥Ïàµ÷ÓõÄÎÊÌ⣬¿ÉÒÔ²éÕÒµ½ºÜ¶à×ÊÁÏ¡£±¾ÎĽ«Ö÷Òª´Ó½â¾öʵ¼ÊÎÊÌâµÄ½Ç¶È¿´ÈçºÎ¹¹½¨Ò»¸öPythonºÍC++»ìºÏϵͳ¡£
&nbs ......
CÓïÑÔ±ØÖª±Ø»á£¨2£©
4.º¯ÊýºÍÖ¸Õë
4.1. Ö¸Ïòº¯ÊýµÄÖ¸Õë
Ö¸Ïòº¯ÊýµÄÖ¸Õ뼴ͨ³£ËµµÄº¯ÊýÖ¸Õ룬ÕýÊÇÓÉÓÚÕâЩ¼ò³Æ£¬ËùÒÔËüºÍ·µ»ØÖ¸ÕëµÄº¯Êý£¨Ö¸Õ뺯Êý£©ÈÝÒ×»ìÏý£¬¶øÇÒÒ²ÓÉÓÚд·¨ÉϱȽÏÏà½ü£¬¾ÍÏñÊý×éÖ¸Õë(int (*p)[4])ºÍÖ¸ÕëÊý×é(int *p[4])Ò»Ñù£¬Ç°Õß±íʾָÕë±äÁ¿pÖ¸ÏòÒ»¸öһάÊý×飬Õâ¸öÊý×éº¬Ó ......