为了账号安全,请及时绑定邮箱和手机立即绑定

请问,goto end;可以用什么函数替换?可以举个例子吗?

请问,goto end;可以用什么函数替换?可以举个例子吗?

www说 2021-09-19 13:13:18
struct student *del(struct student *head,long num){struct student *p1,*p2;if(head==NULL){printf("\n空链表\n");goto end;}p1=head;while(num!=p1->num&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num==p1->num){if(p1==head)head=p1->next;else p2->next=p1->next;printf("删除:%ld\n",num);n=n-1;}else printf("%ld 没有找到!",num);end;return(head);}我用的dev c++,没有end。这个例子是谭浩强书上的。
查看完整描述

1 回答

?
大话西游666

TA贡献1817条经验 获得超14个赞

struct student *del(struct student *head,long num)
{
struct student *p1,*p2;
int flag = 1;
if(head==NULL)
{
printf("\n空链表\n");
flag = 0;
}
if(flag)
{
p1=head;
while(num!=p1->num&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(num==p1->num)
{
if(p1==head)
head=p1->next;
else p2->next=p1->next;
printf("删除:%ld\n",num);
n=n-1;
}
else printf("%ld 没有找到!",num);
}
return(head);
}



查看完整回答
反对 回复 2021-09-23
  • 1 回答
  • 0 关注
  • 247 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信