#include <stdio.h> #include <stdlib.h> typedef struct _node { int data; struct _node *next; } node; node* reverse1(node * head) { node*p,*q,*r; if( head != NULL ) { p = head; q = head->next; head->next = NULL; while(q){ r = q->next; q->next = p; p = q; q = r; } head=p; } return head; } int main( void ) { node *link = NULL; node *tmp = NULL; int i = 0; for( i = 0; i < 5; i++ ) { tmp = malloc( sizeof( node ) ); if( tmp == NULL ) return -1; tmp->data = i; tmp->next = link; link = tmp; } tmp = link; printf( "before reversal:\n" ); while( tmp ) { printf( "%d ", tmp->data ); tmp = tmp->next; } putchar( '\n' ); link = reverse1( link ); printf( "after reversal:\n" ); tmp = link; while( tmp ) { printf( "%d ", tmp->data ); tmp = tmp->next; } putchar( '\n' ); return 0; } 测了一下,应该可以使吧