Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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);
}


Ïà¹ØÎĵµ£º

ת]C,C++¾­µäÎÊÌ⣬¼°ÃæÊÔ±ÊÊÔÌâ


1       ±à³Ì»ù´¡
1.1    »ù±¾¸ÅÄî
1.         µÄÀí½â£ºconst char*, char const*, char*constµÄÇø±ðÎÊÌ⼸ºõÊÇC++ÃæÊÔÖÐÿ´Î    ¶¼»áÓеÄÌâÄ¿¡£ ÊÂʵÉÏÕâ¸ö¸ÅÄîË­¶¼ÓÐÖ»ÊÇÈýÖÖÉùÃ÷·½Ê½·Ç³£ÏàËÆºÜÈÝÒ׼ǻ졣 Bja ......

CÓïÑԸ߼¶²âÊÔ£ºÎªC³ÌÐòÔ±×¼±¸µÄ0x10¸ö×î¼ÑÎÊÌâ

Õû¸ö²âÊÔ×ñÑ­ÒÔϵÄÔ¼¶¨£º
u
      
¼Ù¶¨ÔÚËùÓеijÌÐòÖбØÐëµÄÍ·Îļþ¶¼ÒѾ­±»ÕýÈ·°üº¬¡£
¿¼ÂÇÈçϵÄÊý¾ÝÀàÐÍ£º
u
      
char
Ϊ
1
¸ö×Ö½Ú
u
      
int
Ϊ
4
¸ö×Ö½Ú
u
      ......

VCÖбàÒëÓÐCÔ´ÎļþµÄ³ÌÐò

×î½üÔÚ×ö³ÌÐòʱÐèҪʹÓÃÒ»¸öÒѾ­±àºÃµÄC³ÌÐòÔ´Îļþ£¨ÓÐÍ·Îļþ£©£¬½«Í·Îļþ¼ÓÈëÒªµ÷ÓõÄÔ´ÎļþÖУ¬µ÷ÓÃÏàÓ¦Cº¯Êý£¬±àÒëʱ³öÏÖÈçÏ´íÎó£º
sss.c(3129) : fatal error C1010: unexpected end of file while looking for precompiled header directive
ÔÚÍøÉϲéÁËÏà¹Ø×ÊÁÏ£¬Ëµ²»ÄÜÔÚCÔ´ÎļþÖаüº¬"stdafx.h"Îļþ£¬
ÖªµÀÐèÒªÒ ......

Tricky C questions



ÒÔÏÂÊǼ¸¸ö¼¬ÊÖµÄ
C ÎÊÌâ, ºÜÄÑ×ö, ¿´¿´×Ô¼º»á×ö¼¸¸ö?
How do you write a program which produces its own source code as its output?
How can I find the day of the week given the date?
Why doesn’t C have nested functions?
What is the most efficient way to count the num ......

C/C++²»¶¨²ÎÊýµÄÓ÷¨

C++²»¶¨²ÎÊýµÄÓ÷¨ £¨CÀàËÆ£©
2009-11-19 15:41
/*
va_list vl; //¶¨ÒåÒ»¸öÖ¸Ïò²ÎÊýÁбíµÄ±äÁ¿(Ò»¸ö...Ö¸Õë)
va_start(vl,first_param); //°ÑÖ¸Ïò²ÎÊýÁбíµÄ±äÁ¿³õʼ»¯
va_arg(vl,mode); //»ñÈ¡ÏÂÒ»¸ö²ÎÊý,²ÎÊýÀàÐÍÓɵڶþ¸ö²ÎÊýÖ¸¶¨,µÚ¶þ¸ö²ÎÊýÓÃÓÚÔÚva_argÄÚ²¿½øÐÐ³ß´ç¼ÆËã,ÒÔ±ãÕÒµ½ÏÂÒ»¸ö²ÎÊý
va_end(vl); //½áÊø
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ