Hol dir Firefox 3 für ein besseres und moderneres Surf-Erlebnis! Dann siehst du uns auch mit runden Ecken ;-)

Quadratische Gleichungen

Hier ien total simples Programm , was eine Quadratische Gleichung mit p/q Formel berechnet ( im softwareunterricht entsanden :D )

#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>

int quaGL(float,float,float,float,float *,float *);

main ()
{
float a, b, c, d;
float x1, x2;

printf ("Bitte geben Sie a ein: ");
scanf ("%i",&a);
printf ("Bitte geben Sie b ein: ");
scanf ("%i",&b);
printf ("Bitte geben Sie c ein: ");
scanf ("%i",&c);
printf ("Bitte geben Sie d ein: ");
scanf ("%i",&d);

if (a==0)
{
printf ("Diese Rechnung ist nicht moeglich , da eine Division durch Null erforderlich ist !");
}
else
{
switch(quaGL(a, b, c, d, &x1, &x2))
{

case (1):
printf ("
Ergebnis x1 : %f
Ergebnis x2 : %f", x1,x2);
break;
case (2):
printf ("
Ergebnis : x1 = %f",x1);
break;
case (3):
printf ("
Ihre Rechnung ergibt keine Loesung !");
break;
}
}
getch();
}

int quaGL (float a, float b, float c, float d, float * X1, float * X2)
{
float p,q,D;
p=b/a;
q=(c-d)/a;
D=(p/2)*(q/2)-q;
if (D>0)
{
* X1=-p/2+sqrt(D);
* X2=-p/2-sqrt(D);
return(1);
}
else
{
if(D==0)
{
* X1=-p/2;
return(2);
}
else
{
return(3);
}
}
}
Erstellt von Puppet111 am 14.03.2005 um 20:38:20.
Zuletzt bearbeitet von Puppet111 am 14.03.2005 um 20:38:20.
Schlagworte: Visual Basic, C, C++

Kommentare

malo, am 17.03.2005 um 16:34:00
Was jetzt noch intersant wäre, is was das nun alles geht?
Da ich noch nie C/++ oder sonstiges Auser PHP / MySQL zu tun hatte.

Das ist wohl eher nen Script als nen Tutorial, würde mich freuen wenn du das Editierst.

Stoke