C语言单向循环链表转双向循环链表#includestdio.h#includemalloc.h#includestdlib.htypedefstructnode{chardata;structnode*pre;structnode*next;}List;List*create_List(){List*head,*s,*p;charch;head=(List*)malloc(sizeof(List));p=head;head-pre=NULL;while((ch=getchar())!='\n'){s=(List*)malloc(sizeof(List));s-data=ch;p-next=s;//s-prior=p;p=s;}s-next=head;//head-prior=s;returnhead;}voidsingleToDu(List*h){List*p,*q;p=h;q=p-next;while(q!=h){q-pre=p;p=q;q=q-next;}q-pre=p;}voidprint_List(List*h){List*p;if(h-pre){printf(链表的前驱指针存在,现采用反向遍历\n);p=h-pre;while(p!=h){printf(--%c,p-data);p=p-pre;}}else{printf(链表的前驱指针不存在,现采用正向遍历\n);p=h-next;while(p!=h){printf(--%c,p-data);p=p-next;}}printf(\n\n);}voidmain(){List*head;head=create_List();print_List(head);singleToDu(head);print_List(head);}