data=c;q" />
#include"stdio.h"
#include "stdlib.h"
typedef struct linklist list;
struct linklist{
char data;
list *next;
};
void createList(list *l)
{
list *p,*q;
char c;
p=l;
while((c=getchar())!='#')
{
q=(list *)malloc(sizeof(list));
q->data=c;
q->next=NULL;
p->next=q;
p=q;
}
}
void NuList(list *l)
{
list *p,*q;
p=l->next;
l->next=NULL;
if(p!=NULL)
{
q=p->next;
while(q!=NULL)
{
p->next=l->next;
l->next=p;
p=q;
q=q->next;
}
p->next=l->next;
l->next=p;
}
}
void showList(list *l)
{
list *p;
p=l->next;
while(p!=NULL)
{
printf("%c\t",p->data);
p=p->next;
}
printf("\n");
}
int main()
{
list *head;
head=(list *)malloc(sizeof(list));
head->next=NULL;
createList(head);
printf("输入的链表为:\n");
showList(head);
NuList(head);
printf("逆序之后的链表为:\n");
showList(head);
return 0;
}