标签:sp c ad line r size bs as return
node *creatline(int n)
{
node *head=(node *)malloc(sizeof(node));
head->data=rand()%100;
head->next=NULL;
node *p=head;
int i=0;
while (i<n-1) {
p->next=(node *)malloc(sizeof(node));
p->next->data=rand()%100;
p->next->next=NULL;
p=p->next;
i++;
}
return head;
}
void printline(node *p)
{
while (p!=NULL) {
printf("%d\n",p->data);
p=p->next;
}
}
void releaseline(node *p)
{
node *q=p->next;
while (p!=NULL)
{
printf("%d\n",p->data);
free(p);
p=q;
if (q!=NULL)
{
q=p->next;
}
}
}
void releaseline2(node *p)
{
node *q=p->next;
printf("%d\n",p->data);
free(p);
if (q!=NULL) {
releaseline2(q);
}
}
标签:sp c ad line r size bs as return
原文地址:http://www.cnblogs.com/a514875560/p/3993713.html