单向循环链表

#include
#include
#define N 9
typedef struct node{
   int  data;
   struct node * next;
}ElemSN;
ElemSN*Createlink(int a[],int n){
int i;
        ElemSN*h=NULL,*p,*t;
        for(i=0;idata=a[i];
    if(!h)        //建立只有一个结点的循环链表
            h=t=p;
    else        //结点数目大于1
            p->next=h;//建立循环链表
    t=t->next=p;//标记链表的尾结点
         }
     return h;
}
void Printlink(ElemSN*h){
     ElemSN*p;
     p=h;
     do{ //do while循环输出
	     printf("%2d\n",p->data);
	     p=p->next;
     }while(p!=h);
}
int main(void){
int a[N]={1,2,3,4,5,6,7,8,9};
ElemSN*head;
head=Createlink(a,9);
Printlink(head);
}

分享名称:单向循环链表
当前地址:http://lszwz.com/article/jgsehd.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款