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

C unsigned int and int

Ê×ÏȽøÐÐÒ»¸öʵÑ飬·Ö±ð¶¨ÒåÒ»¸ösigned intÐÍÊý¾ÝºÍunsigned intÐÍÊý¾Ý£¬È»ºó½øÐдóС±È½Ï£º
unsigned int a=20;
signed int b=-130;
a>b?»¹ÊÇb>a£¿ÊµÑéÖ¤Ã÷b>a£¬Ò²¾ÍÊÇ˵£­130>20,Ϊʲô»á³öÏÖÕâÑùµÄ½á¹ûÄØ£¿
ÕâÊÇÒòΪÔÚCÓïÑÔ²Ù×÷ÖУ¬Èç¹ûÓöµ½ÎÞ·ûºÅÊýÓëÓзûºÅÊýÖ®¼äµÄ²Ù×÷£¬±àÒëÆ÷»á×Ô¶¯×ª»¯ÎªÎÞ·ûºÅÊýÀ´½øÐд¦Àí£¬Òò´Ëa£½20£¬b£½4294967166£¬ÕâÑù±È½ÏÏÂÈ¥µ±È»b>aÁË¡£
ÔÙ¾ÙÒ»¸öÀý×Ó£º
unsigned int a=20;
signed int b=-130;
std::cout<½á¹ûÊä³öΪ4294967186£¬Í¬ÑùµÄµÀÀí£¬ÔÚÔËËã֮ǰ£¬a£½20£¬b±»×ª»¯Îª4294967166£¬ËùÒÔa£«b£½4294967186

¼õ·¨ºÍ³Ë·¨µÄÔËËã½á¹ûÀàËÆ¡£

Èç¹û×÷Ϊsigned intÐÍÊý¾ÝµÄb=-130£¬bÓëÁ¢¼´ÊýÖ®¼ä²Ù×÷ʱ²»Ó°ÏìbµÄÀàÐÍ£¬ÔËËã½á¹ûÈÔȻΪsigned intÐÍ£º
signed int b=-130;
std::cout<Êä³öΪ-100¡£

¶ø¶ÔÓÚ¸¡µãÊýÀ´Ëµ£¬¸¡µãÊý£¨float£¬double£©Êµ¼ÊÉ϶¼ÊÇÓзûºÅÊý£¬unsigned ºÍsignedǰ׺²»ÄܼÓÔÚfloatºÍdoubleÖ®ÉÏ£¬µ±È»¾Í²»´æÔÚÓзûºÅÊý¸ùÎÞ·ûºÅÊýÖ®¼äת»¯µÄÎÊÌâÁË¡£


include
include

define UNSIGNED_SHORT_LT(a , b) (((unsigned short) (((unsigned short) a) - ((unsigned short) b))) > (unsigned short) 0x7fff)
define UNSIGNED_COMP_LT(a , b) ((unsigned int) (((unsigned int) a) - ((unsigned int) b)))

typedef struct test_node {
int num;
struct test_node *next;
} test_node_t;

test_node_t *head;
test_node_t *tail;

void build_link(int num)
{
if (head == NULL) {
test_node_t *tmp = (test_node_t *)malloc(sizeof(test_node_t));
tmp->num = num;
tmp->next = NULL;
head = tail = tmp;
} else {
test_node_t *tmp_add = (test_node_t *)malloc(sizeof(test_node_t));
tmp_add->num = num;
tmp_add->next = NULL;
tail->next = tmp_add;
tail = tmp_add;
}
}

void print_link()
{
test_node_t *p = head;
for (p = head; p; p = p->next)
printf("the %d node address:%x, head:%x, tail:%x\n", p->num, p, head, tail);
}

void clear_link()
{
test_node_t *p = head;

while (p) {
test_node_t *tmp = p;
p = p->next;
printf("free %d node, tmp:%x, p:%x, head:%x, tail:%x\n", tmp->num, tmp, p


Ïà¹ØÎĵµ£º

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 ......

PCÖ®¸¸C. ThackerÈÙ»ñ2009ÄêͼÁé½±


PCÖ®¸¸C. ThackerÈÙ»ñ2009ÄêͼÁé½±
2010-03-10 01:21 |  3110´ÎÔĶÁ |  ¡¾ÒÑÓÐ16ÌõÆÀÂÛ¡¿·¢±íÆÀÂÛ
¹Ø¼ü´Ê£ºÐÂÎÅ×ÊѶ  | ¸ÐлliujiangCEµÄÌṩ |  ÊÕ²ØÕâÆª×ÊѶ
¸ù¾ÝACM¹Ù·½ÍøÕ¾3ÔÂ9ÈÕ·¢²¼µÄÏûÏ¢£¬2009ÄêͼÁé½±ÊÚÓèÁËÏÖ´úPCÖ®¸¸Charles Thacker£¬ÒÔ±íÕÃËû¶ÔµÚһ̨ÏÖ´ú¸öÈ˼ÆËã»úXerox PARC Altoµ ......

GCC ÐÂÊÖ c/c++

±¾ÎÄÊÇд¸ø gcc ÐÂÊÖµÄÈëÃÅÎÄÕ£¬ËùÒÔÄÚÈݱȽϼòµ¥¡£Èç¹ûÄãÖªµÀÏÂÃæ3ÌõÃüÁî¶¼¿ÉÒÔ±àÒëc++µÄ»°£¬¾Í²»ÓÃÔÚ±¾ÎÄÀË·Ñʱ¼äÁË
´úÂë:
g++ -Wall hellocpp.cpp
gcc -Wall hellocpp.cpp -lstdc++
gfortran -Wall hellocpp.cpp -lstdc++
×¢£º±¾ÎÄ×îаæÔÚwikiÖÐ http://wiki.ubuntu.org.cn/Gcchowto
£¨½¨Òé´ó¼ÒÖ±½Ó·ÃÎÊwikiÖ ......

Objective —C µÄµ¥Àýģʽ SingletonʵÏÖ


static
 DataManager 
*
sharedDataManager 
=
 nil;
+
 (DataManager 
*
) sharedManager
{
    @synchronized(self)
 {
        
if
 (sharedDataManager 
==
 nil)
 &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ