n人中m人が当選するくじ
Posted feedbacks - Pascal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | { Free Pascal + Run-Time Library (rtl)
2 args
kuji n m
}
program kuji;
uses
SysUtils;
Var
n, m : Cardinal;
begin
if ParamCount <> 2 then Exit;
n := StrToInt(paramstr(1));
m := StrToInt(paramstr(2));
if n < m then Exit;
Writeln('# n=', IntToStr(n), ' m=', IntToStr(m));
Randomize;
for n := n downto 1 do
begin
if Random(n)+1 <= m then
begin
WriteLn(IntToStr(n));
Dec(m);
end;
end;
end.
|

にしお
#3360()
Rating0/0=0.00
[ reply ]