题目: |
const
SIZE = 100;
var
alive: array [1..SIZE] of integer;
n, m, num, i, j: integer;
function next(num: integer): integer;
begin
repeat
inc(num);
if num > n then
num := 1;
until alive[num] <> 0;
exit(num);
end;
begin
read(n, m);
for i := 1 to n do
alive[i] := 1;
num := 1;
for i := 1 to n do
begin
for j := 1 to m - 1 do
num := next(num);
write(num, ' ');
alive[num] := 0;
if i < n then
num := next(num);
end;
writeln;
end.
输入:11 3 输出:3 6 9 1 5 10 4 11 8 2 7
|