Registriert seit: 6. Apr 2011
Ort: Berlin
3.070 Beiträge
Delphi 10.4 Sydney
|
AW: Delphie Schleifen-Probleme
14. Okt 2020, 12:34
Delphi-Quellcode:
uses
Math;
procedure TForm1.Button1Click(Sender: TObject);
var
ay, by, cy, l1, l2, f1, lf1, f2, lf2, lges, suche: Extended;
t: Integer;
function IsValueValid(const AValue, ARange: Extended): Boolean;
begin
Result := (AValue <= ARange) or (AValue >= ARange);
end;
begin
ay := 0;
by := 0;
cy := 0;
l1 := 0.1;
l2 := 0.1;
f1 := strtofloat(Edit1.Text);
f2 := strtofloat(Edit2.Text);
lf1 := strtofloat(Edit3.Text);
lf2 := strtofloat(Edit4.Text);
lges := strtofloat(Edit5.Text);
suche := (f1 + f2) / 3;
t := 0;
while (l1 < lges) do
begin
while (l2 < lges) do
begin
ay := f1 * (1 - (lf1 * 2 / l1));
by := - f1 + (f1 * lf1 * 2 / l1) + f2 + (f1 * lf1 - f2 * (lf2 - l1)) / l2 + f1;
cy := - 1 * (f1 * (l1 + 2 * l2) * lf1 - f2 * l1 * (l1 - l2 - lf2)) / (l1 * l2);
Inc(t);
l2 := l2 + 0.1;
end;
l1 := l1 + 0.1;
l2 := l1 + 0.1;
end;
Label4.Caption := IntToStr(t);
if IsValueValid(ay, 1.05 * suche) then
Label1.Caption := FloatToStr(ay);
if IsValueValid(by, 1.05 * suche) then
Label2.Caption := FloatToStr(by);
if IsValueValid(cy, 1.05 * suche) then
Label3.Caption := FloatToStr(cy);
end;
|
|
Zitat
|