Registriert seit: 13. Nov 2008
56 Beiträge
Turbo Delphi für Win32
|
Re: Zufallsvariable
22. Nov 2008, 13:59
was ist dann falsch?
Ich kann kein denkfehler erkennen!
Delphi-Quellcode:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
public
z :integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;
z := random(50)+1;
end;
procedure TForm1.Button1Click(Sender: TObject);
var r : real;
begin
r := StrTofloat(edit1.Text);
if r < z then Label2.Caption := ' Zu niedrig'
else if r > z then Label2.Caption := ' Zu hoch'
else if r = z then Label2.Caption := ' Erraten';
end;
end.
|
|
Zitat
|