一个简单的逆序链表操作的C程序 先把head置NULL,再逐一反向就OK了。 #include < stdio.h > #include < stdlib.h > typedef struct List ... { int data; struct List *next; } List; /**/ /* 创建链表 */ List * list_create( void ) ... { List *head,*tail,*p; int e; head=(List *)malloc(sizeof(List)); tail=head; printf(" List Create,input numbers(end of 0):"); scanf("%d",&e); while(e) ...{ p=(List *)malloc(sizeof(List)); p->data=e; tail->next=p; tail=p; scanf("%d",&e); } tail->next=NULL; return head; } /**/ /* 逆序函数 */ List * list_reverse(List * head) ... { List *p,*temp; p = head; head = NULL; while(p) ...{ temp = p; p = p->next; temp->next = head; head = temp; }} int main( void ) ... { struct List *head,*p; int d; head=list_create(); printf(" "); for(p=head->next;p;p=p->next) printf("--%d--",p->data); /**//*end of Create */ head=list_reverse(head); printf(" "); for(p=head;p->next;p=p->next) printf("--%d--",p->data); printf(" "); /**//*getch();*/ /**//*system("pause");*/ return 0;}