Registriert seit: 11. Nov 2004
156 Beiträge
Delphi 2005 Architect
|
Re: polynom fläche berechnen
2. Dez 2004, 15:37
hier die Lösung zu meinem Problem
Delphi-Quellcode:
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label10: TLabel;
Label11: TLabel;
Edit5: TEdit;
Label12: TLabel;
Edit6: TEdit;
Edit7: TEdit;
Button1: TButton;
CH_negFlaeche: TCheckBox;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure Flaechenberechnung(a3, a2, a1, a0, ug, og : real; var erg : real; Bool_Flaeche : bool);
const Anzahl_intervalle = 10000000 ;
var x : real; i : integer;
begin
erg := 0;
x:= ug;
for i:= 0 to Anzahl_intervalle-1 do
begin
if bool_Flaeche = true then
erg := erg + (og-ug)/Anzahl_intervalle* (a3*x*x*x + a2*x*x + a1*x + a0)
else
erg := erg + (og-ug)/Anzahl_intervalle* abs(a3*x*x*x + a2*x*x + a1*x + a0);
x:= x + (og-ug)/Anzahl_intervalle;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var ergebnis : real;
begin
flaechenberechnung(strtofloat(edit1.Text), strtofloat(edit2.Text), strtofloat(edit3.Text), strtofloat(edit4.Text), strtofloat(edit5.Text), strtofloat(edit6.Text), Ergebnis, CH_negFlaeche.checked);
Edit7.Text:= FloatToStrF( Ergebnis, ffFixed, 11,4);
end;
end.
|
|
Zitat
|