Powered by CoCalc
//#define CATCH_CONFIG_RUNNER  // This tells Catch to provide a main() - only do this in one cpp file
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
//#include "catch.hpp"
#include <ratio>
#include <tuple>
//using namespace std;


float a,b,c;
int indikator;

float linsolve( float b, float c )
{
 return -c/b;

}

/*
 TEST_CASE( "Wird die Lineare Gleichung korrekt gelöst?") {
    double b=-2,c=3;

    REQUIRE( linsolve(1,0) == 0 );
    REQUIRE( linsolve(1,1) == -1 );
    REQUIRE( linsolve(-2,3) == -c/b);

  }
*/


int Typ( float a, float b , float c)
{
   if ((a==0)&&(b==0)&&(c==0)) indikator=1; // Fall unendlich viele Lösungen
   else if ((a==0)&&(b==0)&&(c!=0))   indikator=2;  // Fall keine Lösung
   else if (((a==0)&&(b!=0)&&(c==0))||((a==0)&&(b!=0)&&(c!=0))) indikator=3; // Fall Lineare Gleichung
   else indikator=4; // Fall quadratische Gleichung  
   return indikator;

}

/*
 TEST_CASE( "Prüfe die Fallunterscheidungen") {
    REQUIRE( Typ(0,0,0) == 1 );
    REQUIRE( Typ(0,0,1) == 2 );
    REQUIRE( Typ(0,1,0) == 3 );
    REQUIRE( Typ(0,1,1) == 3 );
    REQUIRE( Typ(1,1,1) == 4 );

  }
*/

std::vector<float> diskriminante (float a, float b, float c)
{
  float d=std::pow(b,2)-4*a*c;
  if (d<0) return {0,d};
  else if (d==0) return {1,d};
  else if (d>0) return{2,d};
}

/*
 TEST_CASE( "Prüfe die Diskriminate") {
    std::vector<double> test1 {1,std::pow(-2,2)-4*1*1};
    REQUIRE(  diskriminante(1,-2,1)== std::vector<double> {1,std::pow(-2,2)-4*1*1});

  }
*/

int main()
{
 std::cin >>  a >>  b >>  c;
 //std::cout << " a ist= " << b << " b ist= " << b << " c ist= " << c << "\n";
 indikator=Typ(a,b,c);
 //std::cout << indikator << "\n";

  if (indikator==1) {} //std::cout << // " unendlich viele Lösung";
  else if (indikator==2) {} //std::cout << // " es gibt keine Lösung";
  else if (indikator ==3) std::cout << linsolve(b,c);
  else if (indikator ==4)
     {
      std::vector<float> d=  diskriminante ( a, b, c);
      //for (auto i:d)
      //  std::cout << i << "\n";
      // if (d[0]<0) {} ;
      if (d[0]==1) std::cout << -b/(2*a);
      else if (d[0]==2) std::cout << (-b+sqrt(d[1]))/(2*a) << " "<< (-b-sqrt(d[1]))/(2*a);

      }





  //std::cout << " Fall " << Typ(a,b,c) << "\n";






  //int result = Catch::Session().run();
  //return result;

  }