[C]CÓïÑÔ»ù´¡¹®¹ÌרÌâ const
const ÊÇÔÚ³ÌÐòÖзdz£ÖØÒª¡£ÔÚÕâÀïÎÒ×öһϼòµ¥µÄ½éÉÜ¡£
1.const »ù´¡
constÓÐÁ½ÖÖÐÎʽ:
a) const Type var;
È磺int a =10;const int * var=&a; ÄÇôvar¾ÍÊdz£Á¿Ö¸Õ룬±íÃ÷ÊÇÖ¸Ïò³£Á¿µÄÖ¸Õ룬Ҳ¾ÍÊÇ˵aµÄÖµ²»Äܸı䡣
b) Type const var;
Èç int * const var; var ½Ð×öÖ¸Õë³£Á¿£¬Ö¸ÕëÊdz£Á¿£¬±íÃ÷varÄÚ´æ·ÅµÄµØÖ·²»Äܱ䡣
ÏÂÃæ½éÉÜconst µÄ×÷ÓÃ
2. ¶¨Òå³£Á¿¡£
const int p=10;
pÔÚ³ÌÐòÖоͲ»ÄÜÐÞ¸ÄÁË¡£
Óë#define ¶¨Òå³£Á¿Ïà±È£¬ËüÓÐÒÔϲ»Í¬:
a) define ÔÚÔ¤´¦Àí½×¶ÎÕ¹¿ª£»const ÊDZàÒëÔËÐÐʱʹÓÃ
b) definde ÎÞÀàÐÍ£¬²»½øÐÐÀàÐͼì²é£»const ÓÐÊý¾ÝÀàÐÍ£¬×öÀàÐͼì²é£¬°²È«ÐԸߡ£
c) define ½ö½öÊÇÕ¹¿ª£¬²»·ÖÅäÄڴ棻const ³£Á¿ÓзÖÅ䣬һ°ã·ÖÅäÔÚ³£Á¿Çø¡£
3.ÐÞÊκ¯ÊýµÄ²ÎÊý£¬·µ»ØÖµ¡£
ÐÞÊÎÖµ£º
void function(const int a):a µÄÖµ²»±ä£¬¶ÔÓڸú¯ÊýºÃÏñÒâÒå²»´ó£¬ËùÒÔÕâÖÖ·½Ê½ºÜÉÙÓá£
ÐÞÊÎÖ¸Õ룺
void function(const char * p):±íÃ÷²»ÄÜÐ޸IJÎÊýµÄÖµ£¬
int strcpy(char * dst,const char * src)£»¾ÍÊÇÒ»¸öºÜÃ÷ÏÔµÄÀý×Ó£¬Òª¾ÍÔÚ¸´ÖƵÄʱºò²»¸Ä±äÔÀ´srcµÄÖµ¡£
ÐÞÊÎÒýÓãº
void function(const Class & a);ͨ¹ýÒýÓ㬿ÉÒÔÊ¡µôÁÙʱ¶ÔÏóµÄÉú³É£¬¸´ÖÆ£¬Îö¹¹µÄÏûºÄ£¬ºÄʱ£¬ºÄ¿Õ¼ä¡£
ÒÔÉÏÖ»ÊÇÎҵļòµ¥µÄ×ܽᣬÓв»¶ÔµÄµØ·½£¬ÇëÖ¸Õý£¬Ð»Ð»£¡
Ïà¹ØÎĵµ£º
UVa Online Judge - Volume C ÌâÄ¿ºÍ½â´ðË÷Òý¡£Ç°ÃæΪÔÌâÁ´½Ó£¬ºóÃæΪÎҵĽâ´ðÁ´½Ó¡£
·µ»Ø×ÜĿ¼
10003 - Cutting Sticks
Dynamic Programming
Solution
10004 - Bicoloring
Graph: BFS
Solution
10006 - Carmichael Numbers
Number Theory: Modulus
Solution
10010 - Where's Waldorf?
String
Solution ......
"endian"Õâ¸ö´Ê³ö×Ô<<¸ñÁзðÓμÇ>>,СÈ˹úµÄÄÚÕ½¾ÍÔ´ÓÚ³Ô¼¦µ°Ê±ÊǾ¿¾¹´Ó´óÍ·(Big-Endian)Çÿª»¹ÊÇ´ÓСͷ(Little-Endian)Çÿª.ÎÒÃÇÒ»°ã½«endian·Òë³É"×Ö½ÚÐò",½«big endianºÍlittle endian³Æ×÷"´ó¶Ë"ºÍ"С¶Ë".
ÔÚ¼ÆËã»ú¿ÆѧÁìÓòÖÐ,×Ö½ÚÐòÊÇÖ¸´æ·Å¶à×Ö½ÚÊý¾ÝµÄ×Ö½ÚµÄ˳Ðò,µäÐ͵ÄÇé¿öÊÇÕûÊýÔÚÄÚ´æÖеĴæ·Å·½Ê½ºÍ ......
¶ÔÓںܶà³õѧÕßÀ´Ëµ£¬ÍùÍù¾õµÃ»Øµ÷º¯ÊýºÜÉñÃØ£¬ºÜÏëÖªµÀ»Øµ÷º¯ÊýµÄ¹¤×÷ÔÀí¡£±¾ÎĽ«Òª½âÊÍʲôÊǻص÷º¯Êý¡¢ËüÃÇÓÐʲôºÃ´¦¡¢ÎªÊ²Ã´ÒªÊ¹ÓÃËüÃǵȵÈÎÊÌ⣬ÔÚ¿ªÊ¼Ö®Ç°£¬¼ÙÉèÄãÒѾÊìÖªÁ˺¯ÊýÖ¸Õë¡£
¡¡¡¡Ê²Ã´Êǻص÷º¯Êý£¿
¡¡¡¡¼ò¶øÑÔÖ®£¬»Øµ÷º¯Êý¾ÍÊÇÒ»¸öͨ¹ýº¯ÊýÖ¸Õëµ÷Óõĺ¯Êý¡£Èç¹ûÄã°Ñº¯ÊýµÄÖ¸Õ루µØÖ·£©×÷Ϊ²ÎÊý´«µÝ¸øÁí ......
#include <stdio.h>
int main()
{
int i = 1;
int j = 0;
int k = 0;
for(;i<6;i++)
{
k = i;
for(j = 0;j<i;j++,k++)
{
printf("%d ",k);
}
printf("\n");
}
}
ºÜ¼òµ¥µÄ³ÌÐò£¬¿´ÓÐÈËÎÊ£¬¾ÍÏ´¶öÁ˷ŵ½ÕâÁË¡£¡£¡£
ÐÐÁж¼ºÜÓйæÂÉ¡£¡£¡£¡£
Á½¸öÑ»·¡£¡£¡£
ÔËÐнá¹û ......
.APS£º´æ·Å¶þ½øÖÆ×ÊÔ´µÄÖмäÎļþ£¬VC°Ñµ±Ç°×ÊÔ´Îļþת»»³É¶þ½øÖƸñʽ£¬²¢´æ·ÅÔÚAPSÎļþÖУ¬ÒÔ¼Ó¿ì×ÊÔ´×°ÔØËٶȡ£×ÊÔ´¸¨ÖúÎļþ¡£
.BMP£ºÎ»Í¼×ÊÔ´Îļþ¡£
.BSC£ºä¯ÀÀÐÅÏ¢Îļþ£¬ÓÉä¯ÀÀÐÅϢά»¤¹¤¾ß£¨BSCMAKE£©´ÓÔʼä¯ÀÀÐÅÏ¢Îļþ£¨.SBR£©ÖÐÉú³É£¬BSCÎļþ¿ÉÒÔÓÃÀ´ÔÚÔ´´úÂë±à¼´°¿ÚÖнøÐпìËÙ¶¨Î»¡£ÓÃÓÚä¯ÀÀÏîÄ¿ÐÅÏ¢µÄ£¬Èç¹ûÓ ......