Einzelnen Beitrag anzeigen

thknub

Registriert seit: 25. Apr 2008
12 Beiträge
 
Turbo Delphi für Win32
 
#20

Re: Falls Variable(n) vorhanden mache das sonst mache dies

  Alt 28. Apr 2008, 18:50
So das sieht jetzt vllt. etwas unschön und kompliziert aus, aber es funzt, zumindes zur Hälfte. Wenn ich nur Seiten eingebe kommt trotzdem: Ungültige Gleitkommaoperation Weiß jemand warum?

Delphi-Quellcode:
var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3, h3, i3, j3, k3, l3, m3, n3, o3, p3, q3, r3, s3, t3, u3, v3, w3, x3, y3, z3 : REAL;
    bo1, bo2, bo3, bo4, bo5, bo6, bo7, bo8, bo9, bo10, bo11, bo12, bo13, bo14, bo15, bo16, bo17, bo18, bo19, bo20 :boolean;

begin

{Eingabe}

{Seiten}
a := StrToFloat(edit1.text);
b := StrToFloat(edit2.Text);
c := StrToFloat(edit3.Text);
{Winkel}
d := StrToFloat(edit4.Text);
e := StrToFloat(edit5.Text);
f := StrToFloat(edit6.Text);

{-----------------------------------------------------------------------------}

{Berechnung}

{Variablendefinierung Gradmaß<->Bogenmaß}
g := 2*Pi/360; {Gradmaß -> Bogenmaß}
h := 360/(2*Pi); {Bogenmaß -> Gradmaß}

{Boolean Variablen}
if a>0 then bo1 := True else bo1 := False;
if b>0 then bo2 := True else bo2 := False;
if c>0 then bo3 := True else bo3 := False;
if d>0 then bo4 := True else bo4 := False;
if e>0 then bo5 := True else bo5 := False;
if f>0 then bo6 := True else bo6 := False;

 {Berechnung Seite a}
if bo2 and bo4 and bo5 = True then i := (b*sin(d*g))/sin(e*g) else i := 0;
if bo3 and bo4 and bo6 = True then j := (c*sin(d*g))/sin(f*g) else j := 0;
if bo2 and bo3 and bo4 = True then k := sqrt(sqr(b)+sqr(c)-(2*b*c*cos(d*g))) else k := 0;

{Berechnung Seite b}
if bo1 and bo4 and bo5 = True then l := (a*sin(e*g))/sin(d*g) else l := 0;
if bo3 and bo5 and bo6 = True then m := (c*sin(e*g))/sin(f*g) else m := 0;
if bo1 and bo3 and bo5 = True then n := sqrt(sqr(a)+sqr(c)-(2*a*c*cos(e*g))) else n := 0;

{Berechnung Seite c}
if bo1 and bo4 and bo6 = True then o := (a*sin(f*g))/sin(d*g) else o := 0;
if bo2 and bo5 and bo6 = True then p := (b*sin(f*g))/sin(e*g) else p := 0;
if bo1 and bo2 and bo6 = True then q := sqrt(sqr(a)+sqr(b)-(2*a*b*cos(f*g))) else q := 0;

{Berechnung Winkel Alpha}
if bo1 and bo2 and bo5 = True then r := h*arcsin((a*sin(e*g))/b) else r := 0;
if bo1 and bo3 and bo6 = True then s := h*arcsin((a*sin(f*g))/c) else s := 0;
if bo1 and bo2 and bo3 = True then t := h*arccos(sqr(a)/(sqr(b)+sqr(c)-2*b*c)) else t := 0;
if bo5 and bo6 = True then u := 180-e-f else u := 0;

{Berechnung Winkel Beta}
if bo1 and bo2 and bo4 = True then v := h*arcsin((b*sin(d*g))/a) else v := 0;
if bo2 and bo3 and bo6 = True then w := h*arcsin((b*sin(f*g))/c) else w := 0;
if bo1 and bo2 and bo3 = True then x := h*arccos(sqr(b)/(sqr(a)+sqr(c)-2*a*c)) else x := 0;
if bo4 and bo6 = True then y := 180-d-f else y := 0;

{Berechnung Winkel Gamma}
if bo1 and bo3 and bo4 = True then z := h*arcsin((c*sin(d*g))/a) else z := 0;
if bo2 and bo3 and bo5 = True then a2 := h*arcsin((c*sin(e*g))/b) else a2 := 0;
if bo1 and bo2 and bo3 = True then b2 := h*arccos(sqr(c)/(sqr(a)+sqr(b)-2*a*b)) else b2 := 0;
if bo4 and bo5 = True then c2 := 180-a-b else c2 := 0;

{Berechnung Flächeninhalt A}
if a>b then bo7 := True else bo7 := False;
if a>c then bo8 := True else bo8 := False;
if b>c then bo9 := True else bo9 := False;
if b>a then bo10 := True else bo10 := False;
if c>a then bo11 := True else bo11 := False;
if c>b then bo12 := True else bo12 := False;

{Seite a = Längste Seite}
if bo1 and bo2 and bo3 and bo7 and bo8 = True then d2 := (1/2)*b*c*sin(g*d) else d2 := 0;
{Seite b = Längste Seite}
if bo1 and bo2 and bo3 and bo9 and bo10 = True then e2 := (1/2)*a*c*sin(g*e) else e2 := 0;
{Seite c = Längste Seite}
if bo1 and bo2 and bo3 and bo11 and bo12 = True then f2 := (1/2)*a*b*sin(g*f) else f2 := 0;

{Berechnung Umfang u}
if bo1 and bo2 and bo3 then g2 := a+b+c else g2 := 0;

{----------------------------------------------------------------------------}

{Definierung der Ausgabevariablen}

{Seite a}
if i>0 then h2 := i else h2 := i2;
if j>0 then i2 := j else i2 := j2;
if k>0 then j2 := k else j2 := 0;

{Seite b}
if l>0 then k2 := l else k2 := l2;
if m>0 then l2 := m else l2 := m2;
if n>0 then m2 := n else m2 := 0;

{Seite c}
if o>0 then n2 := o else n2 := o2;
if p>0 then o2 := p else o2 := p2;
if q>0 then p2 := q else p2 := 0;

{Winkel Alpha}
if r>0 then q2 := r else q2 := r2;
if s>0 then r2 := s else r2 := s2;
if t>0 then s2 := t else s2 := t2;
if u>0 then t2 := u else t2 := 0;

{Winkel Beta}
if v>0 then u2 := v else u2 := v2;
if w>0 then v2 := w else v2 := w2;
if x>0 then w2 := x else w2 := x2;
if y>0 then x2 := y else x2 := 0;

{Winkel Gamma}
if z>0 then y2 := z else y2 := z2;
if a2>0 then z2 := a2 else z2 := a3;
if b2>0 then a3 := b2 else a3 := b3;
if c2>0 then b3 := c2 else b3 := 0;

{Flächeninhalt A}
if d2>0 then c3 := d2 else c3 := d3;
if e2>0 then d3 := e2 else d3 := e3;
if f2>0 then e3 := f2 else e3 := 0;

{Umfang u}
if g2>0 then f3 := g2 else f3 := 0;


{Ausgabe}
edit7.Text := FloatToStr(h2);
edit8.Text := FloatToStr(k2);
edit9.Text := FloatToStr(n2);
edit10.Text:= FloatToStr(q2);
edit11.Text:= FloatToStr(u2);
edit12.Text:= FloatToStr(y2);
edit13.Text:= FloatToStr(c3);
edit14.Text:= FloatToStr(f3);





end;

edit:\\ Wenn ich drei Seiten angebe funzt es nicht. Egal ob ich noch zusätzliche Variablen angebe.
  Mit Zitat antworten Zitat