部分正确 ,提示: 段错误,求大神解答
struct ListNode *readlist()
{
struct ListNode *head,*tail,*p;
int t=0;
scanf("%d",&t);
head=tail=NULL;
int size=sizeof(struct ListNode);
while(t!=-1)
{
p=(struct ListNode *)malloc(size);
p->data=t;
if(head==NULL)
{
head=p;
}else{
tail->next=p;
}
tail=p;
scanf("%d",&t);
}
tail->next=NULL;
return head;
}
struct ListNode *getodd( struct ListNode **L )
{
struct ListNode *p,*head,*tail,*head2,*tail2;
p=*L;
head=tail=head2=tail2=NULL;
while(p!=NULL)
{
if(p->data%2!=0)
{
if(head==NULL)
{
head=p;
}else{
tail->next=p;
}
tail=p;
p=p->next;
}else{
if(head2==NULL)
{
head2=p;
}else{
tail2->next=p;
}
tail2=p;
p=p->next;
}
}
tail->next=NULL;
tail2->next=NULL;
*L=head2;
return head;
}
习题11-7 奇数值结点链表 (20分)
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
悬赏问题
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 对于相关问题的求解与代码
- ¥15 ubuntu子系统密码忘记
- ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
- ¥15 保护模式-系统加载-段寄存器
- ¥15 电脑桌面设定一个区域禁止鼠标操作