cs_cricri_forever
Messages postés49Date d'inscriptionmercredi 28 septembre 2005StatutMembreDernière intervention31 mars 2006
-
31 mars 2006 à 02:49
Utilisateur anonyme -
31 mars 2006 à 14:30
Bonjour,
j'aimerais quelque explication, commentaire facile de comprehension sur ceci:
matrices
i,j : integer;
begin
for i:=1 to 4 do
begin
for j:=1 to 4 do
begin
if (i=1) and (j=1)then mata[i,j]:=strtofloat(edit1.Text);
------------------------------------------------------------------
calcul de racine
begin
n:=0;
nombre := StrToFloat(eNombre.Text);
resultat:=(1+nombre)/2;
repeat
resultat0:=resultat;
resultat:=(resultat0+nombre/resultat0)*0.5;
inc(n);
test:=(resultat-resultat0)/resultat0;
if (test<0)then test:=-test;
until(test<0.01);
eRacine.Text := FloatToStr(resultat);
eIteration.Text := IntToStr(n);
------------------------------------------------------------------
equation second degré
begin
x1:=-b/(2*a);
label1.Caption:='X 1 = X 2 = ' +floattostr(x1);
label1.Visible:=true;
end;
if delta > 0 then
begin
if a=0 then
begin
x1:=-c/b;
label7.Visible:=false;
label2.Caption:='X = '+floattostr(x1);
end
else
begin
x1:=(-b -(sqrt(delta)))/(2*a);
x2:=(-b +(sqrt(delta)))/(2*a);
label1.Caption:='X1 = ' +floattostr(x1);
label1.Visible:=true;
label2.Caption:='X2 = ' +floattostr(x2);
end;
cs_cricri_forever
Messages postés49Date d'inscriptionmercredi 28 septembre 2005StatutMembreDernière intervention31 mars 2006 31 mars 2006 à 11:57
Salut francky,
Voila le premier ex.
var
Fadd: TFaddition;
implementation
uses unit1;
{$R *.dfm}
procedure TFaddition.BsommeClick(Sender: TObject);
var
//mata, matb, matr : tableau;
i,j : integer;
begin
//encoder matrice A
for i:=1 to 4 do
begin
for j:=1 to 4 do
begin
if (i=1) and (j=1)then mata[i,j]:=strtofloat(edit1.Text);
if (i=1) and (j=2)then mata[i,j]:=strtofloat(edit2.Text);
if (i=1) and (j=3)then mata[i,j]:=strtofloat(edit3.Text);
if (i=1) and (j=4)then mata[i,j]:=strtofloat(edit4.Text);
if (i=2) and (j=1)then mata[i,j]:=strtofloat(edit5.Text);
if (i=2) and (j=2)then mata[i,j]:=strtofloat(edit6.Text);
if (i=2) and (j=3)then mata[i,j]:=strtofloat(edit7.Text);
if (i=2) and (j=4)then mata[i,j]:=strtofloat(edit8.Text);
if (i=3) and (j=1)then mata[i,j]:=strtofloat(edit9.Text);
if (i=3) and (j=2)then mata[i,j]:=strtofloat(edit10.Text);
if (i=3) and (j=3)then mata[i,j]:=strtofloat(edit11.Text);
if (i=3) and (j=4)then mata[i,j]:=strtofloat(edit12.Text);
if (i=4) and (j=1)then mata[i,j]:=strtofloat(edit13.Text);
if (i=4) and (j=2)then mata[i,j]:=strtofloat(edit14.Text);
if (i=4) and (j=3)then mata[i,j]:=strtofloat(edit15.Text);
if (i=4) and (j=4)then mata[i,j]:=strtofloat(edit16.Text);
end;
end;
//encoder matrice B ;
for i:=1 to 4 do
begin
for j:=1 to 4 do
begin
if (i=1) and (j=1)then matb[i,j]:=strtofloat(edit17.Text);
if (i=1) and (j=2)then matb[i,j]:=strtofloat(edit18.Text);
if (i=1) and (j=3)then matb[i,j]:=strtofloat(edit19.Text);
if (i=1) and (j=4)then matb[i,j]:=strtofloat(edit20.Text);
if (i=2) and (j=1)then matb[i,j]:=strtofloat(edit21.Text);
if (i=2) and (j=2)then matb[i,j]:=strtofloat(edit22.Text);
if (i=2) and (j=3)then matb[i,j]:=strtofloat(edit23.Text);
if (i=2) and (j=4)then matb[i,j]:=strtofloat(edit24.Text);
if (i=3) and (j=1)then matb[i,j]:=strtofloat(edit25.Text);
if (i=3) and (j=2)then matb[i,j]:=strtofloat(edit26.Text);
if (i=3) and (j=3)then matb[i,j]:=strtofloat(edit27.Text);
if (i=3) and (j=4)then matb[i,j]:=strtofloat(edit28.Text);
if (i=4) and (j=1)then matb[i,j]:=strtofloat(edit29.Text);
if (i=4) and (j=2)then matb[i,j]:=strtofloat(edit30.Text);
if (i=4) and (j=3)then matb[i,j]:=strtofloat(edit31.Text);
if (i=4) and (j=4)then matb[i,j]:=strtofloat(edit32.Text);
end;
end;
//Additionner;
for i:=1 to 4 do
begin
for j:=1 to 4 do
begin
matr[i,j]:= mata[i,j] + matb[i,j];
end;
end;
//{matrice résultat};
for i:=1 to 4 do
begin
for j:=1 to 4 do
begin
if (i=1) and (j=1)then edit33.text:=floattostr(matr[i,j]);
if (i=1) and (j=2)then edit34.text:=floattostr(matr[i,j]);
if (i=1) and (j=3)then edit35.text:=floattostr(matr[i,j]);
if (i=1) and (j=4)then edit36.text:=floattostr(matr[i,j]);
if (i=2) and (j=1)then edit37.text:=floattostr(matr[i,j]);
if (i=2) and (j=2)then edit38.text:=floattostr(matr[i,j]);
if (i=2) and (j=3)then edit39.text:=floattostr(matr[i,j]);
if (i=2) and (j=4)then edit40.text:=floattostr(matr[i,j]);
if (i=3) and (j=1)then edit41.text:=floattostr(matr[i,j]);
if (i=3) and (j=2)then edit42.text:=floattostr(matr[i,j]);
if (i=3) and (j=3)then edit43.text:=floattostr(matr[i,j]);
if (i=3) and (j=4)then edit44.text:=floattostr(matr[i,j]);
if (i=4) and (j=1)then edit45.text:=floattostr(matr[i,j]);
if (i=4) and (j=2)then edit46.text:=floattostr(matr[i,j]);
if (i=4) and (j=3)then edit47.text:=floattostr(matr[i,j]);
if (i=4) and (j=4)then edit48.text:=floattostr(matr[i,j]);
end;
end;
end;
cs_cricri_forever
Messages postés49Date d'inscriptionmercredi 28 septembre 2005StatutMembreDernière intervention31 mars 2006 31 mars 2006 à 12:01
pour terminer,
procedure TForm1.Button1Click(Sender: TObject);
var
a,b,c,X ,Y ,resultat : extended ;
Signe, Signe2, Signe3, Signe4, ValeurA, ValeurB, ValeurC : String ;
begin
memo1.Visible:= true;
A := StrToFloat(eA.Text) ;
B := StrToFloat(eB.Text) ;
C := StrToFloat(eC.Text) ;
ValeurA := eA.Text ;
ValeurB := eB.Text ;
ValeurC := eC.Text ;
if A = 1 then
begin
X := b / 2 ;
If B > 0 Then Signe := '+' else Signe := '-' ;
If C > 0 Then Signe2 := '+' else Signe2 := '-' ;
If C - X * X > 0 Then Signe3 := '+' else Signe3 := '-' ;
If X > 0 Then Signe4 := '+' else Signe4 := '-' ;
Memo1.Lines.Clear ;
Memo1.Lines.Add('Soit le polynome :') ;
Memo1.Lines.Add(ValeurA+'x² '+Signe+' '+FloatToStr(abs(B))+'x '+Signe2+' '+FloatToStr(abs(C))) ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('Et soit l'' égualité suivante :') ;
Memo1.Lines.Add('a² + 2ab + b² = Ax² + Bx + C') ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('Calcule de b :') ;
Memo1.Lines.Add('B = 2ab') ;
Memo1.Lines.Add('b = B / 2a') ;
Memo1.Lines.Add('a = 1 donc') ;
Memo1.Lines.Add('b = B / 2') ;
Memo1.Lines.Add('b = '+FloatToStr(b)+' / 2') ;
Memo1.Lines.Add('b = '+FloatToStr(X)) ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('Calcule de C :') ;
Memo1.Lines.Add('C = b² + (C - b²)') ;
Memo1.Lines.Add(ValeurC+' = '+FloatToStr(X*X)+' + ('+ValeurC+' - '+FloatToStr(X*X)+')') ;
Memo1.Lines.Add(ValeurC+' = '+FloatToStr(X*X)+' '+Signe3+' '+FloatToStr(abs(C - X * X))) ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('On remplace le C transformé :') ;
Memo1.Lines.Add(ValeurA+'x² '+Signe+' '+FloatToStr(abs(B))+'x + '+FloatToStr(X*X)+' '+Signe3+' '+FloatToStr(abs(C - X * X))) ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('On factorise avec A² + 2ab + B² = ( a + b )² :') ;
Memo1.Lines.Add('(x '+Signe4+' '+FloatToStr(Abs(X))+')² '+Signe3+' '+FloatToStr(abs(C - X * X))) ;
end else begin
X := B / A / 2 ;
If B/A > 0 Then Signe := '+' else Signe := '-' ;
If C/A > 0 Then Signe2 := '+' else Signe2 := '-' ;
If C/A - X * X > 0 Then Signe3 := '+' else Signe3 := '-' ;
If X > 0 Then Signe4 := '+' else Signe4 := '-' ;
Memo1.Lines.Clear;
Memo1.Lines.Add('Soit le polynome :') ;
Memo1.Lines.Add(ValeurA+'x² '+Signe+' '+ValeurB+'x '+Signe2+' '+ValeurC) ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('On Factorise en divisant tout les membres par A :') ;
Memo1.Lines.Add(ValeurA+' ( '+ValeurA+'x²/'+ValeurA+' '+Signe+' '+ValeurB+'x/2 '+Signe2+' '+ValeurC+'/2 )') ;
Memo1.Lines.Add(ValeurA+' ( x² '+Signe+' '+FloatToStr(B/A)+'x '+Signe2+' '+FloatToStr(C/A)+' )') ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('Et soit l'' égualité suivante :') ;
Memo1.Lines.Add('a² + 2ab + b² = Ax² + Bx + C') ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('Calcule de b :') ;
Memo1.Lines.Add('B = 2ab') ;
Memo1.Lines.Add('b = B / 2a') ;
Memo1.Lines.Add('a = 1 donc') ;
Memo1.Lines.Add('b = B / 2') ;
Memo1.Lines.Add('b = '+FloatToStr(B/A)+' / 2') ;
Memo1.Lines.Add('b = '+FloatToStr(X)) ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('Calcule de C :') ;
Memo1.Lines.Add('C = b² + (C - b²)') ;
Memo1.Lines.Add(FloatToStr(C/A)+' = '+FloatToStr(X*X)+' + ('+FloatToStr(C/A)+' - '+FloatToStr(X*X)+')') ;
Memo1.Lines.Add(FloatToStr(C/A)+' = '+FloatToStr(X*X)+' '+Signe3+' '+FloatToStr(abs(C/A - X * X))) ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('On remplace le C transformé :') ;
Memo1.Lines.Add(ValeurA+' ( x² '+Signe+' '+FloatToStr(B/A)+'x + '+FloatToStr(X*X)+' '+Signe3+' '+FloatToStr(abs(C/A - X * X))+' )') ;
Memo1.Lines.Add('') ;
Memo1.Lines.Add('On factorise avec A² + 2ab + B² = ( a + b )² :') ;
Memo1.Lines.Add(ValeurA+' [( x '+Signe4+' '+FloatToStr(Abs(X))+' )²'+Signe3+' '+FloatToStr(abs(C/A - X * X))+' ]');
Memo1.Lines.Add('') ;
Memo1.Lines.Add('On effectue la multiplication') ;
Memo1.Lines.Add(ValeurA+' ( x '+Signe4+' '+FloatToStr(Abs(X))+' )²'+Signe3+' '+FloatToStr(abs(C/A - X * X)*A));
end;
end;
function TForm1.Sogne(Input : Extended) : Boolean ;
begin
if Input >= 0 then result := true else result := false ;
end;
var
Form1: TForm1;
a,b,c,delta,x1,x2 : extended; // On définit les variables
implementation
{$R *.dfm}
procedure TForm1.BCalculerClick(Sender: TObject);
begin
a:=strtofloat(eAX.text); // Je convertis l'edit eAX en float et je
"l'assigne" à la variable a
b:=strtofloat(eBX.Text); //Idem pour l'edit eBX
c:=strtofloat(eC.Text); // Idem pour l'edit eC
delta:=(b*b)-4*a*c; // Je "pose" delta=b²-4*a*c
label7.Caption:='Delta= ' + floattostr(delta);// Le label7 est
delta + la conversion de delta
en string
label7.Visible:=true; // J'affiche le label
if delta = 0 then // Si delta est nul je fais
begin
x1:=-b/(2*a); //solution X1=-b/(2a)
label1.Caption:='X 1 = X 2 = ' +floattostr(x1); // Le label1
est x1=x2= la conversion
de X1 en string
label1.Visible:=true; // J'affiche le label
end;
if delta > 0 then // Si delta est positif
begin
if a=0 then // ne sert à rien
begin
x1:=-c/b; // idem
label7.Visible:=false;//idem
label2.Caption:='X = '+floattostr(x1);/idem
end//idem
else // cas général
begin
x1:=(-b -(sqrt(delta)))/(2*a); // x1=(-b-racinecarré(delta))/(2a)
x2:=(-b +(sqrt(delta)))/(2*a);// x2=(-b+racinecarré(delta))/(2a)
label1.Caption:='X1 = ' +floattostr(x1);//le label1 est
X1=conversion en string de x1
label1.Visible:=true;// j'affiche le label
label2.Caption:='X2 = ' +floattostr(x2);// le label2 est
x2=conversion en string de x2
end;// erreur : pas ici
label2.Visible:=true;//j'affiche le label2
end;
if delta < 0 then
begin
x1:=-b/2*a; //C'est faux: le resultat fais intervenir les nbres complexes
x2:=sqrt(-delta)/2*a;//C'est faux : idem
label1.Caption:='X1 = ' +floattostr(x1);
label1.Visible:=true;
label2.Caption:='X2 = ' +floattostr(x2)+'i';
label2.Visible:=true;
end;
end;
Bon je m'arrette là,
Je ne sais pas ou tu as choppé tes sources mais :
*Ca été programmé avec les pieds : lol
*Bourré de fautes du point de vue mathématiques