begin process at 2012 02 07 06:07:43
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive Delphi

 > 

Archives

 > 

J'AI BESOIN D'AIDE !!!! :O

 > 

Explication :0


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Explication :0

vendredi 31 mars 2006 à 02:49:08 | Explication :0

cricri_forever

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;

---------------------------------------------------

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))) ;
vendredi 31 mars 2006 à 07:03:03 | Re : Explication :0

Francky23012301

Membre Club
Salut Cricri, Si tu méttais intégralement les sources ca serait mieux : il manque des variables des débuts de code et tout et tout Merci à toi
vendredi 31 mars 2006 à 11:57:20 | Re : Explication :0

cricri_forever

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;

vendredi 31 mars 2006 à 11:58:53 | Re : Explication :0

cricri_forever

voila pour le deuxième,

var
  Form1: TForm1;
  nombre, resultat, resultat0, test : extended;
  n:integer;
implementation

{$R *.dfm}

// Calcul de la racine \\
procedure TForm1.BitBtn1Click(Sender: TObject);
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);
 
  end;

vendredi 31 mars 2006 à 12:00:03 | Re : Explication :0

cricri_forever

voici le troisième

var
  Form1: TForm1;
  a,b,c,delta,x1,x2 : extended;

implementation

{$R *.dfm}

procedure TForm1.BCalculerClick(Sender: TObject);
begin
  a:=strtofloat(eAX.text);
  b:=strtofloat(eBX.Text);
  c:=strtofloat(eC.Text);
  delta:=(b*b)-4*a*c;
  label7.Caption:='Delta= ' + floattostr(delta);
  label7.Visible:=true;
  if delta = 0 then
    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;
      label2.Visible:=true;
    end;
  if delta < 0 then
    begin
      x1:=-b/2*a;
      x2:=sqrt(-delta)/2*a;
      label1.Caption:='X1 = ' +floattostr(x1);
      label1.Visible:=true;
      label2.Caption:='X2 = ' +floattostr(x2)+'i';
      label2.Visible:=true;
    end;
end;

vendredi 31 mars 2006 à 12:01:33 | Re : Explication :0

cricri_forever

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;

MERCi D'aVanCe

vendredi 31 mars 2006 à 14:30:23 | Re : Explication :0

Francky23012301

Membre Club
Bon je t'en fais un rapidement 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 A+ et bonne chance


Cette discussion est classée dans : add, memo1, x1, lines, floattostr


Répondre à ce message

Sujets en rapport avec ce message

TREEVIEW level [ par NOSSYLA ] Bonjour à tous, Voici mon problème: dans un treeview j'ai par exemple: NIVEAU_0 ...NIVEAU_01 ..........NIVEAU_02 etc.. ...NIVEAU_01 ..........NIVEAU_0 LoadHTMLToWebbrowser(Webbrowser1,memo1.Lines); ? [ par Taktaky ] Salut,le Code sa marche bien mais si je recharge le Webbrowser une autre fois avec :LoadHTMLToWebbrowser(Webbrowser1,memo1.Lines); Le c Problème memo/boucle [ par dariusxi ] Bonsoir, je rencontre un problème dans le traitement de données contenues dans un mémo. Je dois récupérer des nombres, chiffres par chiffres contenus Problème sur un RichEdit ! [ par minipod ] On peut faire çà:RichEdit1.Lines.Add('test');Moi je voudrai faire çà:RichEdit1.Lines.Add(3048);en sachant que 3048 est l'Unicode d'un caractère.Le Ric idhttp et IdCookieManager [ par Nutspower ] Salut :) Alors voila, je m'identifie sur un site a l'aide de idHTTP : //------------------ IdHTTP1.Host := 'www.***.com' ; IdHTTP1.Port := 80; if IdHT Un problemme avec un StringGrid ou les cases restent blanches [ par zewishper ] Voila mon probleme : j'ai une stringgrid que je rempli grâce a un memo avec la procédure suivante :procedure TForm1.RemplirTableau();var z,c,l : int Problème de caption popupmenu [ par yodavip ] Bonjour,j'ai actuellement un soucis avec un programme que j'essaue de faire...Je m'explique :J'utilise un Tmemo qui me récupères les données d'un fich memo1.Lines [ par Herostnic ] slt qui, peu m'aide comment faire un botton qui peu compter tout les ligne de memo1 est affiche le resultat .merci davanceet merci Encore Une fois . memo1.lines.delete [ par Herostnic ] jai des notes de 20 etudient dans un memo1- a b 0 9 1 0 1 5 1 9 2 0 je veux faire un botton qui peu permet de suppremer les notes qui sont =15 par ex la commande sql ne se termine pas correctement [ par jeansami ] bonjourj'ai rencontré ce problème, et je ne sais pas où est l'erreur, malgré j'ai utilisé "clear', voici le code<pre class="alt2" dir="ltr" style="BOR


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,622 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales