enum Logic{ERROR, OK};
enum Sexy{boy, girl};
#define NULL 0
typedef struct{
float maths;
float polity;
float english;
float professionClass;
float total;
}Score;
typedef struct{
char name[15];
enum Sexy sexy;
int age;
long number;
char scool;
Score score;
}Student,Elem; /*Jiedian Neirong.*/
typedef struct node{
Student elem;
struct node *next;
}Node; /* Jiedian leixing.*/
typedef struct{
Node *head;
}LinkList; /*this is the instruction of the list.*/
LinkList *Link
void DestroyList(LinkList *l)
void ClearList(LinkList *l)
int CreatList(LinkList *l)
int GetElem(LiskList l,int i,Elem *e)
int IsEmpty(LiskList l)
int GetLenghth(LinkList l)
int ListDelete(LinkList *l,int i,Elem *e)
int ListInsert(LinkList *l,int i,Elem *e)
Node *LocateElem(LinkList l,Elem *e)
Node *NextElem(LinkList *l,Node *e)
Node *PriorElem(LinkList *l,Node *e)
void ClearList(LinkList *l)
{
Node *p;
while(l->head->next)
{p=l->head->next;
l->head->next=p->next;
free(p);
}
}
int CreatList(LinkList *l)
{
l->head=(LinkList*)malloc(sizeof(Node));
if(l->head)
{l->head->next=NULL;
return OK;
}
else return ERROR;
}
void DestroyList(LinkList *l)
{
Node *p;
while(l->head)
{p=l->head;
l->head=l->head->next;
free(p);
}
}
int GetElem(LiskList l,int i,Elem *e)
{
Node *p;
int j;
if(i<1||i>GetLenghth(l))exit ERROR;
for(p=l.head,j=0;j!=i;p=p->next,j++);
*e=p->elem;
}
int IsEmpty(LiskList l)
{
if(l.head->next==NULL)return OK;
else return ERROR;
}
int GetLenghth(LinkList l)
{
Node *p;
int len;
for(p=l.head,len=0;p->head==NULL;p=p->next,len++);
return(len);
}
int ListDelete(LinkList *l,int i,Elem *e)
{
Node *p,*s;
int j;
if(i<1||i>GetLenghth(l))return ERROR;
for(p=l->head,j=0;j<i-1;p=p->next,j++);
s=p->next;
*e=s->elem;
p->next=s->next;
free(s);
return OK;
}
int ListInsert(LinkList *l,int i,Elem *e)
{
Node *p,*s;
int j;
if(i<1||i>GetLenghth(l)+1)return ERROR;
for(p=l.head,j=0;p&&j<i-1;p=p->next,j++);
if(j!=i-1){printf("\nIt is wrong inserted space! ");return ERROR;}
s=(Node*)malloc(sizeof(Node));
if(s==NULL)return ERROR;
s->elem=e;
s->next=p->next;p->next=s;
return OK;
}
Node *LocateElem(LinkList l,Elem *e)
{
Node *p;
for(p=l.head->next;p&&p->elem!=e;p=p->next);
return(p);
}
Node *NextElem(LinkList *l,Node *e)
{
Node *p;
for(p=l.head;p&&p!=e;p=p->next);
if(p)p=p->next;
return p;
}
Node *PriorElem(LinkList *l,Node *e)
{
Node *p;
if(l.head->next==e) return NULL;
for(p=l.head;p->next&&p->next!=e;p=p->next);
if(l->next==e)return p;
else return NULL;
}
main()
{
printf("%d\n", NULL);
}
上面的程序到底错什么了?很郁闷!
还有谁可以告诉我怎么解决多个源文件怎么一起运行!
以及书写头文件的技巧!