public double find_list(int key) //按关键字查找
{
Link current=first;
System.out.println("current:"+current.ddata);
while(current.idata!=key)
{
if(current.next==null)
return 0;
else
current=current.next;
}
System.out.println("find:"+current.ddata);
return current.ddata;
}
public double delete_key(int key) //按关键字删除指定的键值
{
Link dellink=first;
Link previous=first;
while(dellink.idata!=key)
{
if(dellink.next==null)
return 0;
else
{
previous=dellink;
dellink=dellink.next;
}
}
if(dellink==first)
first=first.next;
else
previous.next=dellink.next;
return dellink.ddata; //返回删除的键值
}
单链表实现类2(按关键字查找与删除)
最新推荐文章于 2022-01-28 22:47:37 发布