以下是引用菜鸟上路在2006-10-27 13:22:24的发言:LZ的确实是正向的,没仔细看

void  print_link_list(node *head)//不带头结点
{ if(head->next==NULL)
   {
       printf("%5d-->",
head->info);
       return;
   }
   else
   {
       print_link_list(head->next);
       printf("%5d-->",
head->info);
   }
}
这里没看仔细
 
这说法是错误的,经过验证,仍然是反向的
以下是验证代码:
/* 带头接点*/
#include "Stdio.h"
#include "Conio.h"
typedef int type;
typedef struct Node
{
    type info;
    struct Node *next;
}Node;
void Create(Node *L,int num)
{   /*正向创建链表*/
    int i;
    Node *p,*q;
    Node *s=L;
    L=(Node *)malloc(sizeof(Node));
    p=(Node *)malloc(sizeof(Node));
    printf("Please input the element you want:");
    scanf("%d",&p->info);
    p->next=NULL;
    L->next=s->next=p;
    q=p;
    for (i=1;i<num;i++)
    {
        p=(Node *)malloc(sizeof(Node));
        printf("Please input the element you want:");
        scanf("%d",&p->info);
        p->next=NULL;
        q->next=p;
        q=p;
    }
}
void  print_link_list(Node *head,Node *root)
{
    if(head->next==NULL)
    {
        printf("%5d-->",head->info);
        return;
    }
    else
    {
        print_link_list(head->next,root);
        if (head==root)
            return;
        printf("%5d-->",head->info);
    }
}
int main(void)
{
  Node La;
  Create(&La,5);
  print_link_list(&La,&La);
  getch();
  return 0;
}