var A:array[1..8] of integer; i,p,x,y:integer; begin for i:=1 to 8 do read(A[i]); x:=1; p:=A[x]; for i:=1 to 7 do begin y:=x+i; if y>8 then y:=y-8; A[x]:=A[y]; x:=y; end; A[x]:=p; for i:=1 to 8 do write(A[i],' '); writeln; end;
Zistite, aká musela byť vstupná postupnosť ôsmich čísel.
var i,p:integer; a:array[1..N] of 0..2; begin p:=0; for i:=1 to N do begin i:=i+a[i]; if a[i]=2 then i:=i+N-1; a[i]:=0; end; i:=N; while i>0 do begin if i>N then begin a[i]:=2; i:=i-N; end else a[i]:=1; p:=p-1; i:=i-1; end; end;