Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
21
Task/Josephus-problem/PascalABC.NET/josephus-problem.pas
Normal file
21
Task/Josephus-problem/PascalABC.NET/josephus-problem.pas
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
procedure j(n, k: integer);
|
||||
begin
|
||||
var p := (0..n - 1).ToList;
|
||||
var i := 0;
|
||||
var s := new List<integer>;
|
||||
|
||||
while p.Count > 0 do
|
||||
begin
|
||||
i := (i + k - 1) mod p.Count;
|
||||
s.Add(p[i]);
|
||||
p.RemoveAt(i);
|
||||
end;
|
||||
|
||||
println('Prisoner killing order:', s.SkipLast);
|
||||
println('Survivor:', s.Last);
|
||||
end;
|
||||
|
||||
begin
|
||||
j(5, 2);
|
||||
j(41, 3);
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue