//约瑟夫环
void Joseph_Ring(LoopLink l,int m,int n)
{
if(NULL == l)
{
printf("链表不合法\n");
return;
}
LoopLink p;
LoopLink r;
l -> data = 1;
p = l;
while(p -> next != p)
{
for(int i = 1; i < n; i++)
{
r = p;
p = p -> next;
}
printf("%d\t",p -> data);
r -> next = p -> next;
p = p -> next;
}
printf("%d\n",p -> data);
printf("\n");
}
/二进制
void stack_bin(StackPtr s,int m)
{
if(NULL == s)
{
printf("不合法\n");
return;
}
int e = 0;
int j = 0;
int i = 0;
while(m)
{
e = m % 2;
Stack_push(s,e);
m = m / 2;
j++;
}
while(j)
{
Stack_pop(s);
j--;
}
printf("\n");
}