2个回答
展开全部
#include<stdio.h>
#define size 100
void main()
{
int p[size];
int i,j;
int M,start,N,deleNum,total;
clrscr();
printf("\ninput total M:");
scanf("%d",&M);
if((M>size)||(M<0))
{
printf("\ninput again:");
scanf("%d",&M);
}
for(i=0;i<M;i++)
p[i]=i+1;
printf("input start number:");
scanf("%d",&start);
start=start-1;
printf("input Cycle number N:");
scanf("%d",&N);
total =M;
printf("output Serial number:");
for(i=0;i<total;i++)
{
if(M==1)
printf("\n%d The last one",p[0]);
else
{
deleNum=(start+N-1)%M;
printf("\n%d break the ranks",p[deleNum]);
for(j=deleNum;j<M;j++)
p[j]=p[j+1];
start=deleNum;
M=M-1;
}
}
}
#define size 100
void main()
{
int p[size];
int i,j;
int M,start,N,deleNum,total;
clrscr();
printf("\ninput total M:");
scanf("%d",&M);
if((M>size)||(M<0))
{
printf("\ninput again:");
scanf("%d",&M);
}
for(i=0;i<M;i++)
p[i]=i+1;
printf("input start number:");
scanf("%d",&start);
start=start-1;
printf("input Cycle number N:");
scanf("%d",&N);
total =M;
printf("output Serial number:");
for(i=0;i<total;i++)
{
if(M==1)
printf("\n%d The last one",p[0]);
else
{
deleNum=(start+N-1)%M;
printf("\n%d break the ranks",p[deleNum]);
for(j=deleNum;j<M;j++)
p[j]=p[j+1];
start=deleNum;
M=M-1;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询