#include<math.h>
#include<iostream>
using namespace std;

/* Equation du second degre */

int main(){
  int i;
  double a, b, c, x1, x2, det;

  cout << "Equation a*x*x + b*x + c = 0" << endl;
  cout << "Coefficient a ? "; cin >> a;
  cout << "Coefficient b ? "; cin >> b;
  cout << "Coefficient c ? "; cin >> c;
  if (a == 0.)
    if (b == 0.)
      if (c == 0.)
	i = 3;
      else
	i = 0;
    else{
      i = 1;
      x1 = -c/b;
    }
  else{
    det = b*b - 4.*a*c;
    if (det == 0.){
      // ou eventuellement (fabs(det) < 1.e-15) au cas d'erreurs numeriques
      i = 1;
      x1 = -b/(2.*a);
    }
    else if (det < 0.)
      i = 0;
    else{
      i = 2;
      x1 = (-b - sqrt(det)) / (2.*a);
      x2 = (-b + sqrt(det)) / (2.*a);
    }
  }
  if (i == 0)
    cout << "Pas de racine reelle" << endl;
  else if (i == 1)
    cout << "Une racine reelle : " << x1 << endl;
  else if (i == 2)
    cout << "Deux racines reelles : " << x1 << " et " << x2 << endl;
  else
    cout << "Pas d'equation" << endl;
  return 0;
}
