#include #include #include #include struct cirlink { int x; struct cirlink *pre,*next; } *ps1, *ps2; void printp(struct cirlink *ps) { /* circle link list */ struct cirlink *p; p=ps; printf("the input value is --> "); printf("%d ",p->x); p=p->next; while (p != ps) { printf("%d ",p->x); p=p->next; } printf("\n"); } struct cirlink * create() { char t[20]; int x,n,cc,s,ff; struct cirlink *pp,*p,*ps; printf("give me the data --> "); gets(t); x=strlen(t); ff=0; printf("input string --> %s| length=%d\n",t,x); while (x > 4) { s=0; cc=4; while (cc >= 1) { s=s*10+(t[x-cc]-'0'); cc--; } if (s != 0) { if (ff == 0) { ff=1; ps=pp=p=(struct cirlink *)malloc(sizeof(struct cirlink)); p->x=s; p->next=p->pre=p; } else { p=(struct cirlink *)malloc(sizeof(struct cirlink)); p->x=s; p->pre=pp; p->next=ps; pp->next=p; pp=p; ps->pre=p; } } x-=4; } if (x > 0) { s=0; cc=x; while (cc >= 1) { s=s*10+(t[x-cc]-'0'); cc--; } if (s != 0) { p=(struct cirlink *)malloc(sizeof(struct cirlink)); p->x=s; p->pre=pp; p->next=ps; pp->next=p; pp=p; ps->pre=p; } } return ps; } void main() { struct cirlink *p, *pnext; ps1=create(); printp(ps1); ps2=create(); printp(ps2); }