Kód: Vybrat vše
#include "stdafx.h"
#include <IOSTREAM>
#include <math.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a;
int b;
int c;
double d;
double x1;
double x2;
cout << "Zadej a:\n";
cin >>a;
cout << "Zadej b:\n";
cin >>b;
cout << "Zadej c:\n";
cin >>c;
if ((a==0)&&(b==0)&&(c==0)) { cout << "Nekonecne mnoho reseni."; }
if (a==0)
{
x1 = -c/b;
cout << "Rovnice degererovala na linearni.\n";
cout << x1;
}
else
{
d = b*b - 4*a*c;
if (d < 0)
{
cout << "Nema reseni v oboru realnych cisel.";
}
else
{
x1 = (-b+sqrt(d))/(2*a);
x2 = (-b+sqrt(d))/(2*a);
cout << x1 << "\n";
cout << x2;
}
}
}

