struct stud_node *createlist(){
struct stud_node *head, *tail;
head = tail = NULL;
int number;
while(~scanf("%d", &number) && number!=0){
struct stud_node *p = (struct stud_node*)malloc(sizeof(struct stud_node));
p->num = number;
scanf("%s %d", &p->name, &p->score);
if(head==NULL){
head = tail = p;
continue;
}
tail->next = p;
tail = p;
p->next = NULL;
}
return head;
}
struct stud_node *deletelist( struct stud_node *head, int min_score ){
struct stud_node *p = head;
struct stud_node *t = NULL;
if(head==NULL) return NULL;
else if(head->score<min_score){
printf("%s\n", head->name);
head = head->next;
free(p);
p = NULL;
} else while(p!=NULL){
if(p->score<min_score){
printf("%s\n", p->name);
t = p->next;
p->next = t->next;
free(t);
t = NULL;
}
p = p->next;
}
}
链表
最新推荐文章于 2022-07-26 21:57:51 发布
本文详细探讨了链表作为一种重要的数据结构,它的基本概念、类型(单链表、双链表、环形链表)以及操作(插入、删除、遍历)。通过实例解析链表的优缺点,阐述其在内存管理和算法实现中的应用。
摘要由CSDN通过智能技术生成