不是VIP会员,不能显示答案

题目解答

题目:
program test4;
var a,b:array[1..1000] of integer;
i,j,t,h,n,e:integer;
begin
readln(n);
for i:=1 to n do a[i]:=i;
a[1]:=1;h:=2;t:=n;b[1]:=1;e:=n;
for i:=2 to n do
begin
for j:=1 to 2 do
begin
if h=e+1 then
begin
e:=e-i+1;
break
end;
inc(t);
a[t]:=a[h];
inc(h);
end;
b[a[h]]:=i;inc(h);
end;
for i:=1 to n do
write(b[i],);
end.

输入:10
输出:1 5 7 2 9 6 3 10 8 4
考点: 0
分析:
解答: 报数问题
评论:
老师: 0