C ÓïÑÔµÄÃæÏò¶ÔÏó
C ÓïÑÔµÄÃæÏò¶ÔÏó
ÈçÇ°Ëù˵£¬ÃæÏò¶ÔÏóÊÇÒ»ÖÖÈí¼þÉè¼ÆµÄ˼Ï룬ÊÇÓïÑÔÎ޹صġ£ÔÚ±¾½ÚÖУ¬ÎÒ¾ÙÒ»¸öÁ´±í(list) µÄÀý×ÓÀ´ËµÃ÷ÈçºÎÔÚ C ÓïÑÔÖеÄÉè¼Æ³öÓÐÃæÏò¶ÔÏó·ç¸ñµÄ´úÂë¡£
¶¨Òå½Ó¿Ú
½Ó¿ÚÊÇÃæÏò¶ÔÏóÓïÑÔÖеÄÒ»¸ö±È½ÏÖØÒªµÄ¸ÅÄ½Ó¿ÚÖ»¶ÔÍⲿ³ÐŵʵÏָýӿڵÄʵÌå¿ÉÒÔÍê³ÉʲôÑùµÄ¹¦ÄÜ£¬µ«ÊDz»±©Â¶ÊµÏֵķ½Ê½¡£ÕâÑùµÄºÃ´¦ÊÇ£¬ÊµÏÖÕß¿ÉÒÔÔÚ²»½Ó´¥½Ó¿ÚʹÓÃÕߵĴúÂëµÄÇé¿öÏ£¬¶ÔʵÏÖ½øÐе÷Õû¡£
ÎÒÃÇÀ´¿´¿´Á´±íµÄ½Ó¿Ú¶¨Ò壺
Çåµ¥ 1. Á´±íµÄ½Ó¿Ú¶¨Òå
#ifndef _ILIST_H
#define _ILIST_H
// ¶¨ÒåÁ´±íÖеĽڵã½á¹¹
typedef struct node{
void *data;
struct node *next;
}Node;
// ¶¨ÒåÁ´±í½á¹¹
typedef struct list{
struct list *_this;
Node *head;
int size;
void (*insert)(void *node);// º¯ÊýÖ¸Õë
void (*drop)(void *node);
void (*clear)();
int (*getSize)();
void* (*get)(int index);
void (*print)();
}List;
void insert(void *node);
void drop(void *node);
void clear();
int getSize();
void* get(int index);
void print();
#endif /* _ILIST_H */
IList ½Ó¿ÚÖУ¬¿ÉÒÔÇåÎúµÄ¿´µ½£¬¶ÔÓÚÒ»¸ö list ʵÌå ( Ò²¾ÍÊǶÔÏó ) À´Ëµ£¬¿ÉÒÔÔÚÆäÉÏ ½øÐÐ insert, drop, clear, getSize, get(index) ÒÔ¼° print µÈ²Ù×÷¡£
½Ó¿ÚµÄʵÏÖ
Çåµ¥ 2. ¹¹Ôì·½·¨
Node *node = NULL;
List *list = NULL;
void insert(void *node);
void drop(void *node);
void clear();
int getSize();
void print();
void* get(int index);
List *ListConstruction(){
list = (List*)malloc(sizeof(List));
node = (Node*)malloc(sizeof(Node));
list->head = node;
list->insert = insert;// ½« insert º¯ÊýʵÏÖ×¢²áÔÚ li
Ïà¹ØÎĵµ£º
µÝ¹éÁ´±í·´Ðò
void Invert(struct node *p)
{
if(p->next==NULL) return;
if(p->next->next!=0)
Invert(p->next);
p->next->next = p;
p-> ......
(Ò»)ÕûÊý·ûºÅµÄÏÝÚå
(¶þ)¸¡µãÊýµÄ±¾ÖÊ
(Èý)¶ÑÕ»µÄÄÚ´æ¹ÜÀí½á¹¹
(ËÄ)·ûºÅ½âÎö
(Îå)¶ÔÆëºÍ×ÜÏß´íÎó
(Áù)º¯ÊýÖ¸Õë
(Æß)Ð麯ÊýµÄʵÏÖ»úÀí
(°Ë)ÒýÓõÄʵÏÖ»úÀí
(¾Å)ÐéÄâ¼Ì³Ð¶ÔÏóµÄÄÚ´æ½á¹¹
(Ê®)»ìºÏ±à³ÌʱµÄ³õʼ»¯Ë³Ðò
(ʮһ)Êý×éºÍÖ¸ÕëµÄÒìͬ ......
externÊÇC/C++ÓïÑÔÖбíÃ÷º¯ÊýºÍÈ«¾Ö±äÁ¿×÷Ó÷¶Î§£¨¿É¼ûÐÔ£©µÄ¹Ø¼ü×ÖËü¸æËß±àÒëÆ÷£¬ÆäÉùÃ÷µÄº¯ÊýºÍ±äÁ¿¿ÉÒÔÔÚ±¾Ä£¿é»òÆäËüÄ£¿éÖÐʹÓá£
1¡£¶ÔÓÚextern±äÁ¿À´Ëµ£¬½ö½öÊÇÒ»¸ö±äÁ¿µÄÉùÃ÷£¬Æä²¢²»ÊÇÔÚ¶¨Òå·ÖÅäÄÚ´æ¿Õ¼ä¡£Èç¹û¸Ã±äÁ¿¶¨Òå¶à´Î£¬»áÓÐÁ¬½Ó´íÎó
2¡£Í¨³££¬ÔÚÄ£¿éµÄÍ·ÎļþÖжԱ¾Ä£¿éÌṩ¸øÆäËüÄ£¿éÒýÓõĺ¯ÊýºÍÈ«¾Ö±äÁ ......
±¾ÎĽéÉÜÁËʹÓÃPro*C/C++ÔÚVisual
C++»·¾³Ï¿ª·¢OracleÊý¾Ý¿â½Ó¿Ú³ÌÐòµÄ·½·¨
Éè¼Æ˼·ÆäʵÕâÑù£ºÊ×ÏÈͨ¹ýVC½¨Á¢Ò»¸ö¹¤³Ì£¬×Ô¶¯»¯½¨Á¢MAKEFILE£¬UNIXÐèÒª×Ô¼ºÐ´MAKEFILE¡£
Æä´ÎÅäÖÃVCµÄ»·¾³£¬½«PROCµÄ.H£¬.LIBµÄ·¾¶¼ÓÈëDERECTIRY¡£Ð´Ò»¸öPCÎļþ£¬¼´PROCÎļþ¡£·Åµ½¹¤³ÌÏàÓ¦µÄĿ¼Ï¡£È»ºó°ÑPCÎļþ¼ÓÈ빤³Ì¡£Ê¹ÓÃPROCUI.E ......
1.1 ±äÁ¿×÷ÓÃÓò
1.1.1 ¼¸ÖÖ³£¼ûÀàÐͱäÁ¿µÄ×÷ÓÃÓò
×÷ÓÃÓò£¨scope£©»òÕ߿ɼûÐÔÊÇÖ¸±äÁ¿ÔÚ³ÌÐòÄڵĿɼûºÍ¿ÉÒýÓõķ¶Î§¡£
±ÈÈç:
1¡¢ È«¾Ö±äÁ¿ÔÚËùÓеÄÎļþ¶¼¿É¼û£¬ÄÇËûµÄ×÷ÓÃÓò¾ÍÊÇËùÓÐÎļþ£»
2¡¢ static¶¨ÒåµÄÈ«¾Ö±äÁ¿£¬Ö»ÔÚ¶¨ÒåËüµÄÔ´ÎļþÖпɼû£¬ÄÇËûµÄ×÷ÓÃÓò¾ÍÊÇÆäËùÔÚµÄÔ´Îļþ£»
3¡¢ º¯ÊýÄÚ²¿µÄ¾Ö²¿±äÁ¿£¬Ö»ÔÚÆ亯Êý ......