struct man
{
int id;
man *next;
};
struct man *GetMan(int sum)
{
struct man *p,*head;
int i,j;
p=NULL;
head=NULL;
for(i=0;i<sum;i++)
{
if(p==NULL){p=(struct man *)malloc(sizeof(struct man));head=p;}
else
{
p->next=(struct man *)malloc(sizeof(struct man));
p=p->next;
}
p->id=i+1;
p->next=NULL;
}
p->next=head;
return head;
}
main()
{
struct man *pman,*p;
int i;
pman=GetMan(17);
while(pman!=pman->next)
{
for(i=0;i<1;i++)
{
pman=pman->next;
}
p=pman->next;
pman->next=p->next;
pman=pman->next;
free(p);
}
printf("the number is:%d\n",pman->id);
free(pman);
return 0;
}