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

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。
这个例子是谭浩强书上的。

www说
浏览 253回答 1
1回答

大话西游666

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);}
打开App,查看更多内容
随时随地看视频慕课网APP