#include<stdio.h>#include<stdlib.h>#defineN9typedefstructnode{intdata;structnode*next;}ElemSN;ElemSN*Createlink(inta[],intn){inti;ElemSN*h,*p;h=p=(ElemSN*)malloc(sizeof(ElemSN));h->next=NULL;for(i=0;i<N;i++){p=p->next=(ElemSN*)malloc(sizeof(ElemSN));p->data=a[i];p->next=NULL;}returnh;}voidprintlink(ElemSN*h){ElemSN*p;for(p=h;p->next;p=p->next)printf("%2d\n",p->next->data);}voidPrelink(ElemSN*h){ElemSN*p,*r;r=h->next;//头指针后移,给r指针h->next=NULL;//h断开,避免形成环(是一个头指针与第一个结点的环)while(r){//头指针为空,链表遍历完p=r;//当前的结点r=r->next;//r后移(头指针),保证链表有头指针p->next=h->next;//挂链(逆置)h->next=p;//建立新的头结点}}intmain(void){inta[N]={1,2,3,4,5,6,7,8,9};ElemSN*head;head=Createlink(a,9);Prelink(head);printlink(head);}