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: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) EEingabe: TEdit; Ea: TEdit; Eb: TEdit; Ec: TEdit; Ed: TEdit; Ee: TEdit; Ef: TEdit; BWuerfeln: TButton; procedure BWuerfelnClick(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.BWuerfelnClick(Sender: TObject); var a,b,c,d,e,f : real; i, eingabe, zufall : integer; begin a:=0; b:=0; c:=0; d:=0; e:=0; f:=0; zufall:=0; eingabe:=StrToInt(EEingabe.Text); for i:=0 to eingabe do begin randomize; zufall:=random(6)+1; if zufall = 1 then a:=a+1 else if zufall = 2 then b:=b+1 else if zufall = 3 then c:=c+1 else if zufall = 4 then d:=d+1 else if zufall = 5 then e:=e+1 else if zufall = 6 then f:=f+1 else f:=f; end; a:=a/eingabe; b:=b/eingabe; c:=c/eingabe; d:=d/eingabe; e:=e/eingabe; f:=f/eingabe; Ea.Text:=FloatToStr(a); Eb.Text:=FloatToStr(b); Ec.Text:=FloatToStr(c); Ed.Text:=FloatToStr(d); Ee.Text:=FloatToStr(e); Ef.Text:=FloatToStr(f); end;
end. |