Posted on 2009-07-27 15:41
尹泉 阅读(442)
评论(0) 编辑 收藏 引用 所属分类:
算法
1: struct link
2: {
3: int data;
4: struct link *next;
5: };
6:
7: link reverse(link x)
8: {
9: if( NULL==x )
10: return NULL;
11:
12: link t=NULL;
13: link r=NULL, y=x; //(0)
14: while(y!=NULL)
15: {
16: t = y->next; //(1)
17: y->next = r; //(2)
18: r = y; //(3)
19: y = t; //(4)
20: }
21:
22: return r; //返回逆置后的链表
23: }