int Insert(struct ListNode* head,int i,char x)
{
//在第i个位置之前插入新元素 ,成功插入返回1
struct ListNode *p=head,*s;
int j=1;
while(p!=NULL&&j<i-1)//寻找第i-1个结点 用p指向它
{
p =p->next ;
j++;
}
if(j!=i-1)
{
printf("插入位置不合适\n");
return 0;
}
//生成一个空结点
if</
【数据结构】单链表插入算法
最新推荐文章于 2024-05-04 23:04:01 发布