#include <stdio.h>
#define MAXN 20
void CountOff(int n, int m, int out[]);
int main()
{
int out[MAXN], n, m;
int i;
scanf("%d %d", &n, &m);
CountOff(n, m, out);
for (i = 0; i < n; i++)
printf("%d ", out[i]);
printf("\n");
return 0;
}
void CountOff(int n, int m, int out[])
{
int i, count, j, a[MAXN], k;
for (i = 0; i < n; i++)
a[i] = i + 1;
i = 0, k = 0, count = 0, j = 0;
while (count < n)
{
if (a[i] != 0)
k++;
if (k == m)
{
j++;
out[i] = j;
k = 0;
count++;
a[i] = 0;
}
i++;
if (i == n)
i = 0;
}
}
浙大版《C语言程序设计(第3版)》题目集 习题8-4 报数 (20分)
猜你喜欢
转载自blog.csdn.net/qq_44458489/article/details/105376133
今日推荐
周排行