链表是建立
struct Data
{
int num;
int score;
struct Data *next;
};
struct Data *input() { struct Data *head,*p1,*p2; p1=(struct Data*)malloc(LEN); p2=(struct Data*)malloc(LEN); n=0; scanf("%d",&p1->num); while(p1->num!=0) { scanf("%d",&p1->score); n++; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(struct Data*)malloc(LEN); scanf("%d",&p1->num); } p2->next=NULL; return head; }
链表的释放
void Free_List(struct Data *Head) { struct Data *Pointer=NULL; while (NULL != Head) { Pointer = Head; Head = Head->Next; // 下一个节点 free(Pointer); } }
稍后的一些补充