¶Á¡¶CºÍÖ¸Õë¡·±Ê¼ÇÕªÒª¡¾5¡¿
2010-04-09
µÚÊ®ËÄÕ Ԥ´¦ÀíÆ÷
1¡¢#define Ìæ»»
ÔÚ³ÌÐòÖÐÀ©Õ¹#define¶¨Òå·ûºÅºÍºêʱ£¬ÐèÒªÉæ¼°¼¸¸ö²½Ö裻
¢Ù¡¢ÔÚµ÷Óúêʱ£¬Ê×ÏȶԲÎÊý½øÐмì²é£¬¿´¿´ÊÇ·ñ°üº¬ÁËÈκÎÓÉ#define¶¨ÒåµÄ·ûºÅ£¬Èç¹ûÊÇ£¬ËüÃÇÊ×Ïȱ»Ìæ»»£»
¢Ú¡¢Ìæ»»ÎļþËæºó±»²åÈëµ½³ÌÐòÖÐÔÀ´ÎļþµÄλÖ㬶ÔÓں꣬²ÎÊýÃû±»ËûÃǵÄÖµÌæ´ú£»
¢Û¡¢×îºó£¬ÔٴζԽá¹ûÎı¾½øÐÐɨÃ裬¿´¿´ËüÊÇ·ñ°üº¬ÁËÓÉ#define¶¨ÒåµÄ·ûºÅ£¬Èç¹ûÊÇ£¬¾ÍÖظ´ÉÏÊö´¦Àí¹ý³Ì£»
2¡¢ºê²ÎÊýºÍ#define¶¨Òå¿ÉÒÔ°üº¬ÆäËû#define¶¨ÒåµÄ·ûºÅ£¬µ«ÊǺ겻¿ÉÒÔ³öÏֵݹ飻
3¡¢#define PRINT( FORMAT, VALUE ) \
printf( "the value of "#VALUE" is "FORMAT" \n", VALUE )
4¡¢ºêÓëÀàÐÍÎÞ¹Ø
5¡¢ÏÂÃæµÄÖ´Ðнá¹û£º
#define MAX( a, b ) ( (a) > (b) ? (a) : (b) )
z = MAX( x++, y++ ); (ÆäÖÐx = 5£»y = 8)
½á¹û£ºx = 6£»y = 10£»z = 9£»
ÔÒò£ºz = ( (x++) > (y++) ? (x++) : (y++));
6¡¢#undef (Ô¤´¦ÀíÖ¸ÁÓÃÓÚÒƳýÒ»¸öºê¶¨Òå)
7¡¢Ìõ¼þ±àÒ룺ÔÚ±àÒëÒ»¸ö³ÌÐòʱ£¬Èç¹ûÎÒÃÇ¿ÉÒÔÑ¡ÔñijÌõÓï¾ä»òij×éÓï¾ä£¬½øÐзÒë»òÕß±»ºöÂÔ£¬³£³£ÏԵúܷ½±ã¡£Ö»ÓÃÓÚµ÷ÊÔ³ÌÐòµÄÓï¾ä¾ÍÊÇÒ»¸öÃ÷ÏÔµÄÀý×Ó£¬ËûÃDz»Ó¦¸Ã³öÏÖÔÚ³ÌÐòµÄ²úÆ·°æ±¾ÖУ¬µ«ÊÇÄã¿ÉÄܲ¢²»Ïñ°ÑÕâЩÓï¾ä´ÓÔ´´úÂëÖÐÎïÀíɾ³ý£¬ÒòΪÐèҪһЩά»¤ÐÔÐÞ¸Äʱ£¬Äã¿ÉÄÜÐèÒªÖØе÷ÊÔÕâ¸ö³ÌÐò£¬»¹ÐèÒªÕâЩÓï¾ä£»
8¡¢Ìõ¼þ±àÒ룺#if ³£Á¿±í´ïʽ ——Õâ¸öÓÉÔ¤´¦ÀíÆ÷½øÐÐÇóÖµ
statement
#endif
9¡¢Ëùν³£Á¿±í´ïʽ£¬¾ÍÊÇ˵Ëü»òÕßÊÇ×ÖÃæÖµ³£Á¿»òÕßÊÇÒ»¸ö#define¶¨ÒåµÄ·ûºÅ£¬Èç¹û±äÁ¿ÔÚÖ´ÐÐÆÚÇ°ÎÞ·¨»ñµÃËûÃǵÄÖµ£¬ÄÇôËûÃÇÈç¹û³öÏÖÔÚ³£Á¿±í´ïʽÖоÍÊÇ·Ç·¨µÄ£¬ÒòΪËûÃǵÄÖµÔÚ±àÒëʱÊDz»¿ÉÔ¤²âµÄ£»
10¡¢Ìõ¼þ±àÒ룺
#if ³£Á¿±í´ïʽ
statement
#elif ³£Á¿±í´ïʽ
statement
#else
other statement
#endif
11¡¢ÅжÏÊÇ·ñ±»¶¨Ò壺
¢Ù¡¢#if defined(´ýÅжÏÃû)
¢Ú¡¢#ifdef ´ýÅжÏÃû
¢Û¡¢#if !defined(´ýÅжÏÃû)
¢Ü¡¢#ifndef ´ýÅжÏÃû
ÆäÖÐ#ifµÄ¹¦ÄܸüÇ¿£¡£¡
12¡¢Í·ÎļþǶÌ×£¬±ê×¼ÒªÇó±àÒëÆ÷±ØÐëÖÁÉÙÖ§³Ö8²ãµÄÍ·ÎļþǶÌ×£¬Ò»°ãÀ´Ëµ£¬Ò»µ½Á½²ãÒ²²î²»¶à£»
13¡¢¶àÖØ°üº¬ÔÚ¾ø´ó¶àÊýÇé¿öϳöÏÖÓÚ´óÐͳÌÐòÖУ¬ËüÍùÍùÐèҪʹÓúܶàÍ·Îļþ£¬Òò´ËÒª·¢ÏÖÕâÖÖÇé¿ö²¢²»ÈÝÒ×£¬Òª½â¾öÕâÖÖÎÊÌ⣬ÎÒ
Ïà¹ØÎĵµ£º
1.
printf("%.9lf\n",sum);
//Êä³öСÊýµãºó9λ²»Ê¡È¥Ä©Î²¶àÓàµÄ0
2.
printf("%.10g\n",sum);
//Êä³öСÊýµãºó9λ²»Ê¡È¥Ä©Î²¶àÓàµÄ0
3.
#include<iomanip>
cout<<setprecision(10)<<sum<<endl;
//Êä³öСÊýµãºó9λʡȥĩβ¶àÓàµÄ0
4.
#include<iomanip>
cout.pre ......
[root@localhost test]# hexdump -s 0 -n 52 -C helloworld
00000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010 02 00 03 00 01 00 00 00 10 83 04 08 34 00 00 00 |............4...|
00000020 30 08 00 00 00 00 00 00 34 00 20 ......
C/S Óë B/S
£±£®Ó²¼þ»·¾³²»Í¬:
¡¡¡¡C/S Ò»°ã½¨Á¢ÔÚרÓõÄÍøÂçÉÏ, С·¶Î§ÀïµÄÍøÂç»·¾³, ¾ÖÓòÍøÖ®¼äÔÙͨ¹ýרÃÅ·þÎñÆ÷ÌṩÁ¬½ÓºÍÊý¾Ý½»»»·þÎñ.
¡¡¡¡B/S ½¨Á¢ÔÚ¹ãÓòÍøÖ®ÉϵÄ, ²»±ØÊÇרÃŵÄÍøÂçÓ²¼þ»·¾³,ÀýÓëµç»°ÉÏÍø, ×âÓÃÉ豸. ÐÅÏ¢×Ô¼º¹ÜÀí. ÓбÈC/S¸üÇ¿µÄÊÊÓ¦·¶Î§, Ò»°ãÖ»ÒªÓвÙ×÷ϵͳºÍä¯ÀÀÆ÷¾ÍÐÐ&n ......
×ÖËÑË÷¾ÍËÑË÷Ò»¸öÊýÖоßÓÐijЩÌØÕ÷µÄλ¡£ÊµÏÖÈçÏ£º
/* wsearch.c£º×ÖËÑË÷ */
/* ´Ó×ó±ßÑ°ÕÒµÚÒ»¸ö0×Ö½Ú£ºµÚ0(1,2,3)¸ö×Ö½ÚÊÇ0ʱ£¬·µ»Ø0(1,2,3)£¬·ñÔò·µ»Ø4 */
int zbytel(unsigned x){
if((x>>24)==0) return 0;
else if((x & 0x00ff0000)==0) return 1;
else if((x & 0x0000ff00)==0) r ......
ÔÚGmail TopLanguage Group Öп´µ½Ò»ÆªÎÄÕ“C/C++³ÌÐòÔ±±Ø¶ÁµÄÊ®±¾Ê飨ÉÏ£©”£¬´ó¼ÒµÄÌÖÂÛ¶¼ºÜ¼¤Àø£¬´ó¼Ò¶¼¾õµÃÕâƪÎÄÕÂдµÃºÜ°ô£¬ÎÒÏëÔÚGroupÀïµÄÅóÓѶ¼ÄÜÔÚLookgirlµÄÕâƪÎÄÕÂÀï»ñÒæ²»ÉÙ£¬Îª´Ë¶·µ¨ÔÚ´ËתÔظÃÎÄ£¬¹©¸ü¶àÅóÓѽ»Á÷¡¢Ñ§Ï°¡£
C/C++³ÌÐòÔ±±Ø¶ÁµÄÊ®±¾Ê飨ÉÏ£©
Õâ¸öÌâÄ¿´óµÄÓÐЩÀëÆ×£¬Êµ»°Ëµ£ ......