📄 baoshu.c
字号:
#define nmax 50
main()
{
int i,k,m,n,num[nmax],*p,x,y;
printf("please input the total of numbers: m=");//总人数
scanf("%d",&n);
if (n>50)
{
printf("the number must be less than 50");
goto stop;
}
printf("please input the first called number: n=");//第一个出列的人
scanf("%d",&x);
if (x>n)
{
printf("n must be less than m");
goto stop;
}
p=num;
for(i=0;i<n;i++)//给每个人编号
*(p+i)=i+1;
i=0;
k=0;
m=0;
y=0;
while(m<n-1)
{
if(*(p+i)!=0) k++;//没出列,下一个报
if(k==x)//如果报到该出列的数
{
x=*(p+i);//以出列的人的编号作为新的n值
printf("the next out:");
printf("%d",x);
*(p+i)=0;//出列
printf("the rest team:");
for(y=0;y<n;y++)
{
if(*(p+y)==0)
continue;
printf("%d",*(p+y));
}
k=0;//从头计数
m++;//(m不会超过n-1)
}
i++;
if(i==n) i=0;//报到最后从头开始
}
while(*p==0) p++;//扫描队列,看看最后一个是谁
printf("the last one is:");
printf("%d",*p);
stop: printf("there is an error.");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -