(
typedef struct node
{int data;∥假定結點數據域為整型
struct node *next;
}node
LinkedList creat( )
{LinkedList head
int x;
head=(LinkedList)malloc(sizeof(node));
head
scanf(
while(x!=
{p=(LinkedList)malloc(sizeof(node));
p
p
head
scanf(
}
return(head);
}∥結束creat函數
LinkedList invert
/*逆置單鏈表*/
{LinkedList p=head
head
while(p!=null)
{r=p
p
head
p=r;
}
return(head);
}/*結束invert
main()
{LinkedList la;
la=creat( ); /*生成單鏈表*/
la=invert
}
(
LinkedList invert
{p=la
la
while(p!=null)
{r=p
p
la
}
}∥結束算法
[
From:http://tw.wingwit.com/Article/program/sjjg/201311/23333.html