#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include "CircleLinkList.h"
#define M 8
#define N 3
typedef struct MYNUM
{
CircleLinkNode *node;
int val;
}MyNum;
void MyPrint(CircleLinkNode *data)
{
MyNum *mynum=(MyNum*)data;
printf("num:%d\t",mynum->val);
}
int main(void)
{
MyNum mynum[M];
CircleList *list=Init_LinkList();
for(int i=0;i<M;i++)
{
mynum[i].val=i+1;
//这里卡了好久,因为我要【i】加了.num
Insert_CircleLinkList(list,i,(CircleLinkNode*)&mynum[i]);
}
Print_CircleLinkList(list,MyPrint);
int index=1;
CircleLinkNode *pCurrent=list->head.next;
while(Size_CircleLinkList(list)>1)
{
if(index==N)
{
MyNum* tenNum=(MyNum*)pCurrent;
printf("%d\n",tenNum);
//缓存结点的下一个结点
CircleLinkNode *pNext=pCurrent->next;
//根据位置剔除
Remove_CircleLinkList(list,N);
pCurrent=pNext;
if(pCurrent==&(list->head))
{
pCurrent=pCurrent->next;
}
index=1;
}
pCurrent=pCurrent->next;
index++;
}
if(Size_CircleLinkList(list)==1)
{
printf("结束\n");
}
PressSpace_CircleLinkList(list);
}