»ªÎªC/C++±ÊÊÔÌâ(¸½´ð°¸)
http://www.teecool.com/post/2007081104.html
ÄÚÈÝÕªÒª£º1.д³öÅжÏABCDËĸö±í´ïʽµÄÊÇ·ñÕýÈ·, ÈôÕýÈ·, д³ö¾¹ý±í´ïʽÖÐ aµÄÖµ(3·Ö)
int a = 4;
(A)a += (a++); (B) a += (++a) ;(C) (a++) += a;(D) (++a) += (a++);
¹Ø¼ü´Ê£ºCÓïÑÔÃæÊÔÌâ C++ÃæÊÔÌâ »ªÎªÃæÊÔÌâ
±¾ÎĵØÖ·£ºhttp://www.teecool.com/post/2007081104.html
ÄÚÈÝÕýÎÄ£º
1.д³öÅжÏABCDËĸö±í´ïʽµÄÊÇ·ñÕýÈ·, ÈôÕýÈ·, д³ö¾¹ý±í´ïʽÖÐ aµÄÖµ(3·Ö)
int a = 4;
(A)a += (a++); (B) a += (++a) ;(C) (a++) += a;(D) (++a) += (a++);
a = ?
´ð£ºC´íÎó£¬×ó²à²»ÊÇÒ»¸öÓÐЧ±äÁ¿£¬²»Äܸ³Öµ£¬¿É¸ÄΪ(++a) += a;
¸Äºó´ð°¸ÒÀ´ÎΪ9,10,10,11
2.ij32λϵͳÏÂ, C++³ÌÐò£¬Çë¼ÆËãsizeof µÄÖµ(5·Ö).
char str[] = “http://www.ibegroup.com/”
char *p = str ;
int n = 10;
Çë¼ÆËã
sizeof (str ) = £¿£¨1£©
sizeof ( p ) = £¿£¨2£©
sizeof ( n ) = £¿£¨3£©
void Foo ( char str[100]){
Çë¼ÆËã
sizeof( str ) = £¿£¨4£©
}
void *p = malloc( 100 );
Çë¼ÆËã
sizeof ( p ) = £¿£¨5£©
´ð£º£¨1£©17 £¨2£©4 £¨3£© 4 £¨4£©4 £¨5£©4
3. »Ø´ðÏÂÃæµÄÎÊÌâ. (4·Ö)
(1).Í·ÎļþÖÐµÄ ifndef/define/endif ¸ÉʲôÓã¿Ô¤´¦Àí
´ð£º·ÀֹͷÎļþ±»Öظ´ÒýÓÃ
(2). ££i nclude ºÍ ££i nclude “filename.h” ÓÐʲôÇø±ð£¿
´ð£ºÇ°ÕßÓÃÀ´°üº¬¿ª·¢»·¾³ÌṩµÄ¿âÍ·Îļþ£¬ºóÕßÓÃÀ´°üº¬×Ô¼º±àдµÄÍ·Îļþ¡£
(3).ÔÚC++ ³ÌÐòÖе÷Óñ» C ±àÒëÆ÷±àÒëºóµÄº¯Êý£¬ÎªÊ²Ã´Òª¼Ó extern “C”ÉùÃ÷£¿
´ð£ºº¯ÊýºÍ±äÁ¿±»C++±àÒëºóÔÚ·ûºÅ¿âÖеÄÃû×ÖÓëCÓïÑԵIJ»Í¬£¬±»extern "C"ÐÞÊεıä
Á¿ºÍº¯ÊýÊÇ°´ÕÕCÓïÑÔ·½Ê½±àÒëºÍÁ¬½ÓµÄ¡£ÓÉÓÚ±àÒëºóµÄÃû×Ö²»Í¬£¬C++³ÌÐò²»ÄÜÖ±½Óµ÷
ÓÃC º¯Êý¡£C++ÌṩÁËÒ»¸öC Á¬½Ó½»»»Ö¸¶¨·ûºÅextern“C”À´½â¾öÕâ¸öÎÊÌâ¡£
(4). switch()Öв»ÔÊÐíµÄÊý¾ÝÀàÐÍÊÇ?
´ð£ºÊµÐÍ
4. »Ø´ðÏÂÃæµÄÎÊÌâ(6·Ö)
(1).Void GetMemory(char **p, int num){
*p = (char *)malloc(num);
}
void Test(void){
char *str = NULL;
GetMemory(&str, 100);
strcpy(str, "hello");
printf(str);
}
ÇëÎÊÔËÐÐTest º¯Êý»áÓÐʲôÑùµÄ½á¹û£¿
´ð£ºÊä³ö“hello”
(2). void Test(void){
char *str = (char *) malloc(100);
strcpy(str, “hello”);
free(str);
if(str != NULL){
strcpy(str, “worl
Ïà¹ØÎĵµ£º
Boss˵£¬Òª¿´OpenGL£¬¿´ÁË¿ìÒ»¸öÔ£¬×ÜËã³öÁ˸öÏñÑùµÄ¶«Î÷£¬ÓÃCдÁ˸ö3DÃÔ¹¬£¬
ËäȻֻÓÐ350ÐÐ
´úÂ룬²»¹ý±ßѧ±ßд£¬×ã×ãдÁËÒ»ÖÜʱ¼ä£¬»¹ÊÇСÓгɾ͸еģ¬»î»î»î£¡
&n ......
C/C++ÖÐnearºÍfarµÄÇø±ð
¹Ø¼ü×ÖnearºÍfarÊÜÄ¿±ê¼ÆËã»úÌåϵ½á¹¹µÄÓ°Ï졣Ŀǰ±à³ÌÖÐʹÓò»¶à¡£
near¹Ø¼ü×Ö´´½¨Ò»¸öÖ¸Ïò¿ÉÑ°Ö·ÄÚ´æµÍ¶Ë²¿·ÖµÄÄ¿±êÖ¸Õë¡£ÕâЩָÕëÕ¼ÓÃÄÚ´æµÄµ¥Ò»×Ö½Ú£¬²¢ÇÒËûÃÇÄܹ»Ö¸ÏòµÄÄÚ´æµ¥Ôª±»ÏÞÖƵ½256¸öλÖã¬Í¨³£ÊÇÔÚ0x0000~0x00ff·¶Î ......
C ºÍ C++ ×Ö·û´®×ÖÃæÁ¿£¨String Literal£©¼ÈÓÐÏà֮ͬ´¦£¬ÓÖÓÐһЩÇø±ð¡£Á˽âÕâЩÄÚÈݶÔÓÚ¼ÓÉî×Ö·û´®×ÖÃæÁ¿ÒÔ¼°Ïà¹ØһЩ¸ÅÄîµÄÀí½â¡¢³ÎÇåһЩ³£¼ûµÄ¸ÅÄîÎóÇø²»ÎÞÖúÒæ¡£±¾ÎÄÒÔÆÕͨ×Ö·û´®×ÖÃæÁ¿ "hello" ΪÀý×ܽá˵Ã÷ÈçÏ¡£
Ïàͬµã£º
×Ö·û´®×ÖÃæÁ¿ÊǶÔÏó
C/C++ ÖеĶÔÏó£¨Object£©Ö¸µÄÊÇÒ»¿é´æ´¢Çø¡£×Ö·û´®×ÖÃæÁ¿ÊDz»ÐèÒª´´ ......
1¡¢´ÓN¸öÊýÖÐÑ¡³ön¸ö×î´óµÄÊý£¬Ð´³ö˼·ºÍʵÏÖ¡£
¡¶±à³ÌÖ®ÃÀ¡·ÉÏÓн²Õâ¸öËã·¨µÄÉè¼ÆÓë˼·¡£
ÎÒÕâÀï¼òµ¥Ð´¼¸¸ö˼·£º
£¨a£©Èç¹ûNÄÜÔÚÖ÷´æÖÐÒ»´Î¶ÁÈ룬ÔòÏȽøÐпìÅÅ£¬È»ºóÔÙÈ¡Ç°n¸öÊý¡£Ëã·¨¸´ÔӶȣºO(NlogN).
£¨b£©Èç¹ûN·Ç³£´ó£¬¼ÙÉè²»ÄÜÒ»´Î¶ÁÈëÄڴ棬²¢ÇÒn²»ÊǺܴóµÄ»°£¬¿ÉÒÔά»¤Ò»¸ön¸öÔªËصÄÓÐÐò¶ÓÁУ¬¶ÓÁÐÖж¼ÊÇÿ¸ ......
http://sculibin.bokee.com/5628909.html
1.ÒýÑÔ
¡¡¡¡±¾ÎĵÄд×÷Ä¿µÄ²¢²»ÔÚÓÚÌṩC/C++³ÌÐòÔ±ÇóÖ°ÃæÊÔÖ¸µ¼£¬¶øÖ¼ÔÚ´Ó¼¼ÊõÉÏ·ÖÎöÃæÊÔÌâµÄÄÚº¡£ÎÄÖеĴó¶àÊýÃæÊÔÌâÀ´×Ô¸÷´óÂÛ̳£¬²¿·ÖÊÔÌâ½â´ðÒ²²Î¿¼ÁËÍøÓѵÄÒâ¼û¡£
¡¡¡¡Ðí¶àÃæÊÔÌâ¿´ËƼòµ¥£¬È´ÐèÒªÉîºñµÄ»ù±¾¹¦²ÅÄܸø³öÍêÃÀµÄ½â´ð¡£ÆóÒµÒªÇóÃæÊÔÕßдһ¸ö×î¼òµ¥µÄstrcpyº¯Ê ......