Pagini recente » Cod sursa (job #2183438) | Cod sursa (job #1860941) | Cod sursa (job #2861348) | Cod sursa (job #2799563) | Cod sursa (job #46985)
Cod sursa(job #46985)
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 n=1 then i:=1;
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.