Pagini recente » Cod sursa (job #1843551) | Cod sursa (job #1802520) | Cod sursa (job #478158) | Cod sursa (job #1741109) | Cod sursa (job #47004)
Cod sursa(job #47004)
var a:array[1..30000]of integer;
n,i,j,x,s,l:integer;
begin
assign(input,'order.in');
reset(input);
assign(output,'order.out');
rewrite(output);
readln(n);
for i:=1 to n do a[i]:=i;
i:=1;
j:=1;
while n>0 do
begin
i:=i+j;
if i>n then i:=i mod n;
if i=0 then i:=n;
write(a[i],' ');
for l:=i+1 to n do
begin
a[l-1]:=a[l];
end;
a[n]:=0;
n:=n-1;
j:=j+1;
i:=i-1;
end;
close(output);
end.