C ѧϰ±Ê¼Ç£º ÒÆÎ»²Ù×÷Á·Ï°¡£
#include <stdio.h>
unsigned int reverse_bits(unsigned int value)
{
unsigned int answer;
unsigned int i;
answer = 0;
for(i=1;i!=0;i<<=1){ //´ËÑ»·¿ÉÒÔºöÂÔ»úÆ÷µÄ²îÒì¡£64λºÍ32λ½Ô¿ÉÓã¬ÔöÇ¿´Ë´úÂëµÄ¿ÉÒÆÖ²ÐÔ
answer <<=1;
if(value & 1)
answer |= 1;
value >>=1;
}
return answer;
}
int main(void)
{
unsigned int get_answer=reverse_bits(13);
int i=31;
char t;
while(i)
{
t ='0'+ ((get_answer >> i) & 1);
printf("%c",t);
i--;
}
}
<<CºÍÖ¸Õë>> µÚ5ÕÂÁ·Ï°Ìâ¡£
Linux 2.6 kernelÖеÄset_bit²Ù×÷£º
ÐèÒª¿¼ÂÇ»úÆ÷ÊÇ32λ»¹ÊÇ64λµÄ¼ÆËã»ú¡£
static inline void set_bit(int nr, volatile unsigned long *addr)
{
int *a = (int *)addr;
int mask;
//unsigned long flags;
a += nr >> 5;
mask = 1 << (nr & 0x1f);
//local_irq_save_hw(flags);
*a |= mask;
//local_irq_restore_hw(flags);
}
Ïà¹ØÎĵµ£º
£¨×¢£¬±¾ÎÄÊÇ·ÒëµÄhttp://www.cprogramming.com/
ÉϵÄÎÄÕ Where C and C++ Differ
£©
C++»ùÓÚC£¬Ò²±£ÁôÁËCµÄ´ó²¿·ÖÌØÐÔ¡£µ«ÊÇÔÚÔ´Âë¼¶ÉÏÓÐЩµØ·½ÊÇÓëC²»¼æÈݵġ£
C³ÌÐòԱʹÓÃC++ʱµÄÏÝÚå
´Ó void* µÄÒþʽ·ÖÅä
²»ÄÜ´Ó void* ÒþʽµØ·ÖÅäµ½ÆäËûÈκÎÀàÐÍ¡£ÀýÈ磬ÏÂÃæµÄ´úÂëÔÚCÖÐÊǷdz£ÓÐЧµÄ¡£
in ......
B/S½á¹¹£¬¼´Browser/Server£¨ä¯ÀÀÆ÷/·þÎñÆ÷£©½á¹¹£¬ÊÇËæ×ÅInternet¼¼ÊõµÄÐËÆð£¬¶ÔC/S½á¹¹µÄÒ»Öֱ仯»òÕ߸ĽøµÄ½á¹¹¡£ÔÚÕâÖÖ
½á¹¹Ï£¬Óû§½çÃæÍêȫͨ¹ýWWWä¯ÀÀÆ÷ʵÏÖ£¬Ò»²¿·ÖÊÂÎñÂß¼ÔÚǰ¶ËʵÏÖ£¬µ«ÊÇÖ÷ÒªÊÂÎñÂß¼ÔÚ·þÎñÆ÷¶ËʵÏÖ£¬ÐγÉËùν3-tier½á¹¹¡£B/S½á¹¹£¬Ö÷ÒªÊÇ
ÀûÓÃÁ˲»¶Ï³ÉÊìµÄWWWä¯ÀÀÆ÷¼¼Êõ£¬½áºÏä¯ÀÀÆ÷µÄ¶àÖ ......
C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâÐ©ÍøÕ¾Ìṩc/c++Ô´´úÂë¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶ÓÄúµÄ½¨Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ¼Æ ......
C/C++ÓïÑÔʵÏÖ¶¯Ì¬Êý×é
CÊý×éµÄСÎÊÌâ
ÕâÀï˵µÄ¶¯Ì¬Êý×éÊÇ¿ÉÒÔ¸ù¾ÝÐèÒª¶¯Ì¬Ôö³¤Õ¼ÓÃÄÚ´æµÄÊý×飬±ÈÈç³ÌÐò³õʼ·ÖÅäÁË100¸öÔªËØ£¬¿ÉÊÇÔËÐÐÁËÒ»¶Îʱ¼äºóÇøÇø100¸ö¿Õ¼ä²»ÄÜÂú×ãÁË£¬ÏÖÔÚÐèÒª400¸ö£¬Ôõô°ìÄØ£»Äǿ϶¨ÐèÒªÔÙ¶îÍâ·ÖÅä300¸ö¡£
CÓïÑÔÓÐrealloc()º¯ÊýÀ´½â¾ö¿Õ¼ä ......
×ÛÊö
¿´Ò»ÏÂÊäÈë²Ù×÷µÄÔÀí£¬
³ÌÐòµÄÊäÈë¶¼½¨ÓÐÒ»¸ö»º³åÇø£¬¼´ÊäÈ뻺³åÇø¡£Ò»´ÎÊäÈë¹ý³ÌÊÇÕâÑùµÄ£¬µ±Ò»´Î¼üÅÌÊäÈë½áÊøÊ±»á½«ÊäÈëµÄÊý¾Ý´æÈëÊäÈ뻺³åÇø£¬¶øcinµÈÊäÈëÊä³öº¯ÊýÖ±½Ó´ÓÊä
È뻺³åÇøÖÐÈ¡Êý¾Ý¡£ÕýÒòΪcinµÈÊäÈëÊä³öº¯ÊýÊÇÖ±½Ó´Ó»º³åÇøÈ¡Êý¾ÝµÄ£¬ËùÒÔÓÐʱºòµ±»º³åÇøÖÐÓвÐÁôÊý¾Ýʱ£¬cinº¯Êý»áÖ±½ÓÈ¡µÃÕâЩ²ÐÁôÊý¾ ......