Einzelnen Beitrag anzeigen

Thorben_K

Registriert seit: 22. Okt 2006
Ort: Darmstadt
105 Beiträge
 
Delphi 2006 Professional
 
#10

Re: nochmal n-maliges Würfeln

  Alt 4. Feb 2007, 09:44
Altanative ginge auch noch

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  zahlen : array[1..6] of LongInt;
  wurf, i, count : LongInt;
  Comp : TComponent;
begin

  randomize;
  count := StrToInt(Edit1.Text);
  for i := 1 to 6 do
    zahlen[i] := 0;
  for i := 0 to count -1 do
  begin
    wurf := Random(6) +1;
    Inc(zahlen[wurf]);
  end;

  for i := 1 to 6 do
  begin
    comp := FindComponent('Label'+ IntToStr(i));
   (Comp as TLabel).Caption := IntToStr(zahlen[i]);
  end;
end;
so ist es meiner bescheidenen Meinung nach einfach

gruss Thorben

EDIT: Oh da hatte wohl jemand die selbe Idee, das gut, das sagt mit das die idee gar net so schlecht ist
Thorben
  Mit Zitat antworten Zitat