#include<iostream>
using namespace std;
int main()
{
int n, m;
cin >> n, cin >> m;
int* p = new int[n];
for (int i = 0;i < n;i++)
{
*(p + i) = 1;//都在场
}
int j = 0;//计数
int nn = n;//总数
for (int i = 0;i < n&&nn>1;i++)
{
if (*(p + i) == 1)
{
j++;
}
while (j == m)
{
*(p + i) = 0;
nn--;
cout << i + 1 << " ";
j = 0;
}
if (i == n - 1)
i = -1;
}
}
C++报数出局
最新推荐文章于 2025-04-03 17:19:13 发布