#include<>#include<>typedefstructnode{chardata;structnode*nextPtr;}*LinkList,Lnode;staticvoidCreateList(LinkList*headPtr,LinkList*tailPtr,charch);pose(LinkList*headPtrA,LinkList*headPtrB,LinkList*tailPtrB);staticvoidVisitList(LinkListheadPtr);staticvoidDestroyList(LinkList*headPtr,LinkList*tailPtr);intmain(void){LinkListheadPtrA=NULL,tailPtrA=NULL,headPtrB=NULL,tailPtrB=NULL;charch;while(1){printf("Enterch('@'-quit):");scanf("%c",&ch);if(ch=='@'){break;}else{CreateList(&headPtrA,&tailPtrA,ch);}}VisitList(headPtrA);/*打印分解前的链表*/if(headPtrA!=NULL)/*链表不空的情况对其进行分解*/{pose(&headPtrA,&headPtrB,&tailPtrB);/*对链表进行分解*/}else{printf("headPtrAisempty.\n");}VisitList(headPtrA);/*打印分解后的链表*/VisitList(headPtrB);DestroyList(&headPtrA,&tailPtrA);/*销毁链表*/DestroyList(&headPtrB,&tailPtrB);return0;}staticvoidCreateList(LinkList*headPtr,LinkList*tailPtr,charch){LinkListnewPtr;if((newPtr=(LinkList)malloc(sizeof(Lnode)))==NULL){exit(1);}newPtr->data=ch;newPtr->nextPtr=NULL;if(*headPtr==NULL){newPtr->nextPtr=*headPtr;*headPtr=newPtr;}else{(*tailPtr)->nextPtr=newPtr;}*tailPtr=newPtr;}pose(LinkList*headPtrA,LinkList*headPtrB,LinkList*tailPtrB){intco
对链表进行奇数与偶数分组 来自淘豆网www.taodocs.com转载请标明出处.