[C]CÓïÑÔ»ù´¡¹®¹ÌרÌâ Á´±íÖ®£¨Á´±í´´½¨ºÍɾ³ý£©
Á´±íÖÐÓÐÁ½¸ö¹Ø¼üµÄ²Ù×÷£º´´½¨ºÍɾ³ý¡£½ñÌìÎҾͶÔÕâÁ½¸ö²Ù×÷½øÐнéÉÜ£¬
´ÓÕâÁ½¸ö²Ù×÷ÖÐѧϰµ½Á´±íµÄ»ù±¾Ó÷¨¡£
1. Create
Create() ÊÇÒ»¸öÁ´±í»ù´¡£¬Ö»Óн¨Á¢ºÃÁ´±í²ÅÄܶÔËü½øÐÐÏàÓ¦µÄ²éÕÒ£¬É¾³ý µÈ¡£
»ù±¾Ëã·¨£º
1.³õʼ»¯
head=NULL;
ls=new test£»
cin>>ls->num;
Í·½áµãÖ¸ÏòNULL£¬ ´´½¨Ò»¸ö½Úµã£¬ÊäÈënum¡£
le £ºÕâ¸öÖ¸ÕëÓÃÓڼǼ×îºóÒ»¸öÔÚÁ´±íÉϵĽڵ㣬·Ç³£useful.
2.½øÈëÑ»·£¬Ìõ¼þÊÇnum!=0.
1) ÅжÏhead==NULL,
Èç¹ûÎªÕæ£¬±íÃ÷Á´±íΪ¿Õ£¬
Ôò½«½ÚµãÁ¬½Óµ½headÉÏ¡£
·ñÔò½«½ÚµãÁ¬µ½×îºóÒ»¸ö½ÚµãÉÏ¡£
2) ΪºóÃæµÄÑ»·×ö×¼±¸
leÇ°ÒÆ:le=ls;
ls ¿ª±Ùнڵ㣬¸³Öµ: ls=new test; cin>>ls->num.
3.ÊÕβ
ÔÚ֮ǰ¶à¿ª±Ù³öÒ»¸ö½Úµã£¬Òª½«Æäɾ³ý£¬ÁíÍâ¾ÍÊÇleÊÇÖ¸Ïò×îºóÒ»¸ö½ÚµãµÄ
£¬ËùÒÔ½«le->next=NULL.
£¨´ËËã·¨»¹ÓиĽøµÄµØ·½£¬ÄǾÍÊÇ¿ÉÒÔÏÈÅжÏnumÊÇ·ñΪ0 ÔÚ¾ö¶¨ÊÇ·ñ¿ª±Ù£©
struct test
{
int num;
test * next;
};
test * head;
test * create()
{
head=NULL;
test * ls,le;
ls=new test;
cin>>ls->num;
le=ls;
while(ls->num!=0)
{
if(head==NULL)
{
head=ls;
}
else{
le->next=ls;
}
le=ls;
ls=new test;
cin>>ls->num;
}
le->next=NULL;
delete ls;
return head;
}
2. Delete
Delete ÊÇÔÚ¸ø¶¨Ò»¸öÁ´±íµÄÍ·½áµãµÄÖ¸ÕëºÍҪɾ³ýµÄÒ»¸öÊý£¬½ø¶ø¶ÔÆäɾ³ý¡£
»ù±¾Ëã·¨ÈçÏ£º
ÓÉÓÚɾ³ýµÄʱºòÒª¿¼ÂÇÈýÖÖÇé¿ö£º
1. Èç¹ûheadΪ¿Õ£¬Ö±½Ó·µ»Ø
2.Èç¹ûɾ³ýµÄΪÊ׽ڵ㣬ÔòÒª½«´Î½ÚµãµÄµØÖ··µ»Ø¸øhead
3.ʣϵÄÇé¿ö¾ÍÊÇÖмäºÍĩβµÄ½Úµ
Ïà¹ØÎĵµ£º
http://os.51cto.com 2008-03-21 11:15 ØýÃû ÈüµÏÍø
ÕªÒª£ºÑ§»áʹÓÃvim/emacs£¬vim/emacsÊÇlinuxÏÂ×î³£ÓõÄÔ´Âë±à¼Æ÷£¬²»¹âҪѧ»áÓÃËüÃDZà¼Ô´Â룬»¹ÒªÑ§»áÓÃËüÃǽøÐвéÕÒ¡¢¶¨Î»¡¢Ìæ»»µÈ¡£ÐÂÊֵϰÍƼöʹÓÃvim£¬ÕâÒ²ÊÇÎÒĿǰʹÓõÄÎı¾±à¼Æ÷¡£
±êÇ©£ºLinux CÓïÑÔ ±à³Ì
Or ......
http://docs.google.com/View?docid=ajbgz6fp3pjh_2dwwwwt#_38239340844832237
It is not about optimization.
The whole idea of using 'do/while' version
is to make a macro which will
expand into a regular statement, not into a
compound statement. This is
done in order to make the use of function-s ......
º¯ÊýÃû: strtok
¹¦ ÄÜ: ²éÕÒÓÉÔÚµÚ¶þ¸ö´®ÖÐÖ¸¶¨µÄ·Ö½ç·û·Ö¸ô¿ªµÄµ¥´Ê
ÓÃ ·¨: char *strtok(char *str1, char *str2);
³ÌÐòÀý:
&nbs ......
c º¯ÊýÖ¸Õë
ÒÔǰʲôº¯ÊýÖ¸Õë,Ö¸Õ뺯Êý½ö½öÊǸÅÄîÉϵÄÀí½â,×î½üд¸ö³ÌÐòÓÐÕâô¸öÐèÇó,ÆäʵҲ²»ÊÇÓÐÕâô¸öÐèÇó,¶øÊÇÕâÑùд¿ÉÒÔʡȥºÜ¶àÊÂ....searchÁËÏÂ,ÕÒµ½Ò»ÆªºÃÎÄ
º¯ÊýÖ¸ÕëÊÇʲô£¿
ÏÈÀ´¿´º¯Êýµ÷ÓÃÊÇÔõô»ØÊ¡£Ò»¸öº¯ÊýÕ¼ÓÃÒ»¶ÎÁ¬ÐøÄÚ´æ¡£µ±µ÷ÓÃÒ»¸öº¯Êýʱ£¬Êµ¼ÊÉÏÊÇÌø×ªµ½º¯ÊýÈë¿ÚµØÖ·£¬Ö´ ......
1.int *p1 = *(int **)p2;
Õâ¸ö±í´ïʽ½«p2Ö¸ÏòµÄÖµµ±×öÖ¸ÕëÀàÐ͸³Öµ¸øp1
£¬½«ÆÕֵͨµ±×öÖ¸ÕëֵʹÓÃ
2.*£¨int **£©p1 = p2£»
Õâ¸ö±í´ïʽ½«p1Ö¸ÏòµÄÖµÐÞ¸ÄΪµÄp2±£´æµÄÖ¸Õë
µÄÖµ£¬½«Ö¸Õëµ±×öÆÕֵͨʹÓÃ
ÕâÊǽñÌì¿´us/OSµÄÄÚ´æ¹ÜÀíµÄʱºò¿´µ½µÄ£¬ÕæÊÇÌ«¾«±ÙÁË
°¦£¬¿´À´×Ô¼ºµÄ¼ûʶ»¹ÊÇÌ«ÉÙÁË£¬ÒÔºóµÃ¼Ó±¶Å ......