#i nclude <stdio.h>
#i nclude <stdlib.h>
#define null 0
struct node
{
int data ;
struct node *next ;
} ;
/*递归输出链表*/
void recurPrint( struct node *list )
{
struct node *temp ;
temp = list -> next ;
if( temp != null )
{
recurPrint( temp ) ;
printf("%d ", temp->data ) ;
}
}
void main()
{
struct node *link , *head ,* temp ;
int i ;
head = malloc( sizeof( struct node ) ) ;
head->data = 0 ;
head->next = null ;
link = head ;
for( i = 1 ; i <= 7; i++)
{
temp = malloc( sizeof( struct node ) ) ;
temp->data = i ;
temp->next = null ;
link->next = temp ;
link = temp ;
}
link = head ;
while( link!=null )
{
printf("%d ", link->data) ;
link = link->next ;
}
printf("/n") ;
link = head ;
recurPrint( link );
getch() ;
}