思路:首先找出最大值,然后再删除
//链表结构体
struct List{
int data;
struct List *next;
}
//求链表最大值
int Max(List l){
int max=0;
List *p;
p=head;
while(p->next)
{
if(p->data>max){
max=p->data;
}
p=p->next;
}
return max;
}
//删除链表中指定值,返回删除的个数
int delete_list(List l,int e){//e表示需要删除的值
int count=0;
List *p,*q;
p=head;
while(p->next){
if(p->data==e){
q=p->next;
p->next=q->next;
count++;
}
p=p->next;
}
return count;
}
新建一链表,调用对应函数即可