/****************************************************************
双向链表原地逆置
****************************************************************/
#include"malloc.h"
#include"stdio.h"
struct node
{ int d;
struct node *next;
}
main()
{ int x;
struct node *r, *head,*p,*q;
head=NULL;
q=NULL;
scanf("%d",&x);
while(x>0)
{ p=(struct node *)malloc(sizeof(struct node));
p->d=x;
p->next=NULL;
if(head==NULL) head=p;
else q->next=p;
q=p;
scanf("%d",&x);
}
p=head;
q=p->next;
p->next=NULL;
while(q!=NULL)
{ r=q->next;
q->next=p;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载