匿名 #4934(2007/12/22 22:05 GMT) [ Delphi ] Rating0/0=0.00
Integerの動的配列をtypeで定義しています。 Delphiは配列操作が苦手なので、できるだけ使わないようにしています。
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 29
type TDynIntArray = array of Integer; function lot(n, m: Integer): TDynIntArray; function NumInArray(num: Integer; arr :TDynIntArray): Boolean; var x: Integer; begin Result := False; for x in arr do if x = num then Result := True; end; var people: TDynIntArray; i: Integer; num_lot: Integer; begin SetLength(people, m); Randomize; for i := 0 to m - 1 do begin repeat num_lot := Random(n) + 1; until not NumInArray(num_lot, people); people[i] := num_lot; end; Result := people; end;
Rating0/0=0.00-0+
[ reply ]
匿名
#4934()
[
Delphi
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]