围圈报数

题面   http://ybt.ssoier.cn:8088/problem_show.php?pid=1334
1
#include<iostream> 2 #include<cstdio> 3 4 using namespace std; 5 6 int n,m,head=1,tail,i,p,cnt; 7 int q[1001]; 8 int main(){ 9 scanf("%d%d",&n,&m); 10 for(i=1;i<=n;i++) 11 q[i]=i; 12 tail=n+1; 13 while(head<tail) 14 { 15 p=q[head]; 16 cnt++; 17 if(cnt!=m) 18 { 19 q[tail]=p; 20 tail++; 21 } 22 else{ 23 cnt=0; 24 printf("%d ",p); 25 } 26 head++; 27 } 28 return 0; 29 30 }
“为什么圆规能画出圆?” “因为心不变,脚在动。”
原文地址:https://www.cnblogs.com/xrj1229/p/9200844.html