/*鍊錶的使用*/
/*建立*/
#include/*分配空間*/
#define null 0
#define len sizeof(struct student)
struct student /*定義結構體*/
;int n;/*全域性變數,記錄結點個數*/
struct student *creat(void)
p2->next=null;
return(head);
}/*輸出*/
void print(struct student * head)
while(p!=null);
}/*刪除*/
struct student *del(struct student *head,long num)
p1=head;
while(num!=p1->num&&p1->next!=null)/*查詢*/
if(num==p1->num) /*找到*/
else
printf("%ld not been found!/n",num);
return(head);
}/*插入*/
struct student *insert(struct student * head, struct student *stud)
else
if(p0->num<=p1->num)
else
p2->next=p0;
p0->next=p1;
}else/*如果新結點的數比所有結點的數都大,則插到最後*/
}n=n+1;/*插入工作完成後,結點數加1*/
return(head);
}main()
printf("/ninput the inserted record:");/*輸入要插入結點*/
stu=(struct student *)malloc(len);
scanf("%ld,%f",&stu->num,&stu->score);
while(stu->num!=0)
}
鍊錶綜合問題
關於帶表頭鍊錶建立,順序排序各節點,順序插入節點,刪除節點,合併的操作。include include define x sizeof xzx typedef struct student 結構體變數 xzx void creat xzx head 建立鍊錶 free p1 p2 next null...
l鍊錶的綜合操作
define null 0 define len sizeof struct student struct student main p2 next null printf head 0x,last 0x n head,p1 鍊錶生成結束 輸出鍊錶 p1 head printf nnow the n...
對鍊錶的綜合操作
對鍊錶的綜合操作 功能有建立,排序,插入,刪除,輸出 include include typedef int elemtype typedef struct nodetype nodetype,linktype linktype create p2 next null free p1 return ...