/*删除链表L中第i个元素*/
Statue ListDelets(StaticLinklist L,int i)
{
int j,k;
if(i<1 ||i>Listlength(L) )
{
return error ;
}
k=max_size-1;
for(j=1;j<=i-1;j++)
{
k=L[k].cur;
}
j=L[k].cur;
L[K].cur=L[j].cur;
Pree_aLL(L,j);
return ok;
}
/*n个人围成圈报数,最后剩下的是几号*/
# include <stdio.h>
# include <stdlib.h>
typedef struct node
{
int data;
struct node*next ;
}
node;
node*create(int a)
{
node*p=NULL,*head;
head=(node*)malloc(sizeof (node));
p= head;
node*s;
int n,i=1;
if(0!=n)
{
while (i<=n)
{
s=(node*)malloc (sizeof (node));
s->data=i++;
p->next=s; //s为第一个结点
p=s;
}
s->next=head->next;
}
free (head);
return s->next;
}
int main()
{
int n=41;
int m=3;
int i;
int s;
node*p=create(s);
node*temp ; //temp为定义的当前结点
m%=n;
while (p!=p->next) //等于时p为空表
{
for(i=1;i<m-1;i++)
{
p=p->next;
}
printf("%d->",p->next->data);
temp=p->next;
p->next=temp->next;
free(temp);
p=p->next;;
}
printf("%d\n,p->data");
return 0;
}
# include<stdio.h>
# include<stdlib.h>
# define CordNumber
typedef struct node
{
int data;
struct node*next ;
}
sqlist,*linklist;
linklist CreateLinkList()
{
linklist head=Null;
linklist s,r;
int i;
int r=head;
for(i=1;i<=CordNumber;i++);
{
s=(linklist)malloc (sizeof (sqlist));
s->data=0;
if(head==Null)
head=0;
else
r->next=s;
r=s;
}
r->next=head;
return head;
}
//发牌顺序计算
void Magician(linklist head)
{
linklist p;
int j;
int CountNumber=2;
p=head;
p->data=1;
while(1)
{
for(j=0;j<CountNumber;j++)
{
p=p->next ;
if(p->data!=0)
{
p->next;
j--;
}
}
if(p->data==0)
{
p->data=CountNumber;
Countnumber++;
if(Countnumber==14)
break ;
}
}
}
//销毁工作
void DestoryList(linklist*list)
{
int main()
{
linklist p;
int i;
p=CreatLinkList();
Magician(p);
printf ("按如下顺序排列:\n");
for (i=0;i<CordNumber;i++)
{
printf ("黑桃%d",p->data);
p=p->next;
}
DestoryList(p);
return 0;
}
}