RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
单向循环链表
#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);
}

当前标题:单向循环链表
URL标题:http://scyingshan.cn/article/jgsehd.html