Einzelnen Beitrag anzeigen

Matz4000

Registriert seit: 21. Dez 2010
14 Beiträge
 
#1

Invalid floating Point operation

  Alt 18. Mai 2011, 17:03
Delphi-Version: 5
Hey Leute..
Kleines Problem:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var Wuerfel,Wurfzahl,Augenzahl,W1,W2,W3,W4,W5,W6,W7,W8,i:integer;
    Warsch:real;
    Feld:array[1..48] of integer;
begin
listbox1.clear;
Wuerfel:=strtoint(edit1.text);
Wurfzahl:=strtoint(edit2.Text);

For i:=1 to 60 DO
 Feld[i]:=0;
Warsch:=0;
 Case Wuerfel OF
  1:Begin
     label1.caption:=inttostr(Wurfzahl);
     For i:= 1 to Wurfzahl Do
      Begin
        W1:=random(6)+1;
        inc(Feld[W1]);
      end;
     For i:=1 to 6 Do
      Begin
        Warsch:=Feld[i]/Wurfzahl;
        listbox1.items.add('Zahl '+inttostr(i)+' = '+floattostr(Warsch));
      end;
    End;
  2:Begin
     For i:= 1 to Wurfzahl Do
      Begin
        W1:=random(6)+1;
        W2:=random(6)+1;
        Augenzahl:=W1+W2;
        inc(Feld[Augenzahl]);
      end;
     For i:=2 to 12 Do
      Begin
        Warsch:=Feld[i]/Wurfzahl;
        listbox1.items.add('Zahl '+inttostr(i)+' = '+floattostr(Warsch));
      end;
    End;

  3:Begin
     For i:= 1 to Wurfzahl Do
      Begin
        W1:=random(6)+1;
        W2:=random(6)+1;
        W3:=random(6)+1;
        Augenzahl:=W1+W2+W3;
        inc(Feld[Augenzahl]);
      end;
     For i:=3 to 18 Do
      Begin
        Warsch:=Feld[i]/Wurfzahl;
        listbox1.items.add('Zahl '+inttostr(i)+' = '+floattostr(Warsch));
      end;
    End;
  4:Begin
     For i:= 1 to Wurfzahl Do
      Begin
        W1:=random(6)+1;
        W2:=random(6)+1;
        W3:=random(6)+1;
        W4:=random(6)+1;
        Augenzahl:=W1+W2+W3+W4;
        inc(Feld[Augenzahl]);
      end;
     For i:=4 to 24 Do
      Begin
        Warsch:=Feld[i]/Wurfzahl;
        listbox1.items.add('Zahl '+inttostr(i)+' = '+floattostr(Warsch));
      end;
    End;
  5:Begin
     For i:= 1 to Wurfzahl Do
      Begin
        W1:=random(6)+1;
        W2:=random(6)+1;
        W3:=random(6)+1;
        W4:=random(6)+1;
        W5:=random(6)+1;
        Augenzahl:=W1+W2+W3+W4+W5;
        inc(Feld[Augenzahl]);
      end;
     For i:=5 to 30 Do
      Begin
        Warsch:=Feld[i]/Wurfzahl;
        listbox1.items.add('Zahl '+inttostr(i)+' = '+floattostr(Warsch));
      end;
    End;
  6:Begin
     For i:= 1 to Wurfzahl Do
      Begin
        W1:=random(6)+1;
        W2:=random(6)+1;
        W3:=random(6)+1;
        W4:=random(6)+1;
        W5:=random(6)+1;
        W6:=random(6)+1;
        Augenzahl:=W1+W2+W3+W4+W5+W6;
        inc(Feld[Augenzahl]);
      end;
     For i:=6 to 36 Do
      Begin
        Warsch:=Feld[i]/Wurfzahl;
        listbox1.items.add('Zahl '+inttostr(i)+' = '+floattostr(Warsch));
      end;
    End;
  7:Begin
     For i:= 1 to Wurfzahl Do
      Begin
        W1:=random(6)+1;
        W2:=random(6)+1;
        W3:=random(6)+1;
        W4:=random(6)+1;
        W5:=random(6)+1;
        W6:=random(6)+1;
        W7:=random(6)+1;
        Augenzahl:=W1+W2+W3+W4+W5+W6+W7;
        inc(Feld[Augenzahl]);
      end;
     For i:=7 to 42 Do
      Begin
        Warsch:=Feld[i]/Wurfzahl;
        listbox1.items.add('Zahl '+inttostr(i)+' = '+floattostr(Warsch));
      end;
    End;
  8:Begin
     For i:= 1 to Wurfzahl Do
      Begin
        W1:=random(6)+1;
        W2:=random(6)+1;
        W3:=random(6)+1;
        W4:=random(6)+1;
        W5:=random(6)+1;
        W6:=random(6)+1;
        W7:=random(6)+1;
        W8:=random(6)+1;
        Augenzahl:=W1+W2+W3+W4+W5+W6+W7+W8;
        inc(Feld[Augenzahl]);
      end;
     For i:=8 to 48 Do
      Begin
        Warsch:=Feld[i]/Wurfzahl;
        listbox1.items.add('Zahl '+inttostr(i)+' = '+floattostr(Warsch));
      end;
    End;

 end;




end;
end.

Das soll son Prog. sein, das die Warscheinlichkeit der gewürfelten Zahlen bei 1-8 Würfeln und x Würfen ausgibt.
Als Fehlermeldung kommt allerdings immer "Invalid floating Point operation"
Hab mich mal informiert, aber die Gründe die ich gelesen haben treffen hier nicht zu. (z.B. durch 0 teilen oder so)...

Help!

Gruß
Michael
  Mit Zitat antworten Zitat