成都创新互联网站制作重庆分公司

单向循环链表

#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://cxhlcq.com/article/jgsehd.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部