#include
#include
#define N 10
#define MAXSIZE 100
typedefintelemtype;
typedefstructsequlist
{
elemtype data[MAXSIZE]; int last;
}SequenList;
SequenList * Init_SequenList() {
SequenList * L; L=(SequenList * )malloc(sizeof(SequenList)); L->last=-1;
return L;
}
intInsert_SequenList(SequenList * L) {
int j; for(j=0;j
}
intDelete_SequenList(SequenList * L,int a) {
int j; if(aL->last) { } else { } return(L->last+1); printf("%d\n",L->data[a]); for(j=a;jlast;j++) L->data[j]=L->data[j+1]; printf("非法位置:\n"); return 0; } return(L->last+1); L->data[j]=j+1; L->last=L->last+1; L->last--;
void main() { } inta,lo,m,n; SequenList * L; printf("从第几个数开始,数几个数后后有人出列:"); scanf("%d%d",&m,&n); L=Init_SequenList(); lo=Insert_SequenList(L); a=m-1; while(lo>0) { } system("PAUSE"); lo=Delete_SequenList(L,a); a=a+n-1; if(a>=lo) a=a%lo;
#include
#include
#define N 10
#define MAXSIZE 100
typedefintelemtype;
typedefstructsequlist
{
elemtype data[MAXSIZE]; int last;
}SequenList;
SequenList * Init_SequenList() {
SequenList * L; L=(SequenList * )malloc(sizeof(SequenList)); L->last=-1;
return L;
}
intInsert_SequenList(SequenList * L) {
int j; for(j=0;j
}
intDelete_SequenList(SequenList * L,int a) {
int j; if(aL->last) { } else { } return(L->last+1); printf("%d\n",L->data[a]); for(j=a;jlast;j++) L->data[j]=L->data[j+1]; printf("非法位置:\n"); return 0; } return(L->last+1); L->data[j]=j+1; L->last=L->last+1; L->last--;
void main() { } inta,lo,m,n; SequenList * L; printf("从第几个数开始,数几个数后后有人出列:"); scanf("%d%d",&m,&n); L=Init_SequenList(); lo=Insert_SequenList(L); a=m-1; while(lo>0) { } system("PAUSE"); lo=Delete_SequenList(L,a); a=a+n-1; if(a>=lo) a=a%lo;