求助,用循环链表解约瑟夫环问题,哪位大神知道哪里错了
#include<stdio.h>#include<stdlib.h>
typedef struct node{
int data;
int Length;
struct node *next;
}seqlist,*pseqlist;
void joselist(pseqlist L,int s,int m,int t);
void main()
{
int k,c,i,n;
pseqlist p,q,jos,head;
head=(pseqlist)malloc(sizeof(pseqlist));
p=(pseqlist)malloc(sizeof(pseqlist));
q=(pseqlist)malloc(sizeof(pseqlist));
head->next=NULL;
printf("输入起始位置\n");
scanf("%d",&k);
printf("输入出列数\n");
scanf("%d",&c);
printf("输入人数\n");
scanf("%d",&n);
p=head->next;
for(i=0;i<n;i++)
{
p->data=i+1;
p=p->next;
}
p=head;//首尾相连
joselist(head,k,c,n);
}
void joselist(pseqlist h,int s,int m,int t)
{
int i,j;
pseqlist p,pr,head;
head=h;
p=(pseqlist)malloc(sizeof(pseqlist));
p=head;
for(i=0;i<s;i++)
p=p->next;
for(i=0;i<t;i++)
{
for(j=0;j<m;j++)
{
pr=p;
p=p->next;
if(p==head)
{pr=p;p=p->next;}
}
printf("%d",p->data);
pr->next=p->next;
free(p);
p=pr->next;
}
}