#define MaxSize 100 typedef struct List { int data[MaxSize]; int length; }*Sqlist;
void InitList(Sqlist &L) { L=(Sqlist)malloc(sizeof(Sqlist)); L->length=0; }
void CreateList(Sqlist &L) { int n,i;
printf(\"您想输入的人数为:\"); scanf(\"%d\ printf(\"最初的顺序表为:\\n\"); for( i=0;i int Delate_Sqlist(Sqlist &L,int i) { int j; if(!L) { printf(\"表不存在\"); return(-1); } if(i<1||i>L->length) { printf(\"删除位置不合法\"); return(0); } for(j=i;j L->data[j-1]=L->data[j]; L->length--; return(1); } int josephus_Sqlist(Sqlist &L,int s,int m) { int s1,i,w; if (!L->length) { printf(\"表中无元素\"); return(0); } s1=s-1; printf(\"输出约瑟夫序列:\"); for(i=L->length;i>0;i--) { s1=(s1+m-1)%i; w=L->data[s1]; printf(\"%d\\ Delate_Sqlist(L,s1+1); } printf(\"\\n\"); return(1); } void main() { int mm,tt; Sqlist L; InitList( L); CreateList(L); printf(\"从第几个开始:\"); scanf(\"%d\ printf(\"您想出列的序号为:\"); scanf(\"%d\ josephus_Sqlist(L,tt,mm); } 因篇幅问题不能全部显示,请点此查看更多更全内容