#include <iostream>
#include <cmath> // Използва се за решаване на корени
using namespace std;
int main() {
int a, b, c; // Това са променливите за решаване на уравнението
char da_produlja_li; // Това е променлива с която ще направим избор
cout << "Решаване на квадратно уравнение Ax^2 + Bx + C = 0" << endl;
// Тука въвеждаме променливите
cout << "Въведете a: ";
cin >> a;
cout << "Въведете b: ";
cin >> b;
cout << "Въведете c: ";
cin >> c;
// Пресмятане на дискриминанта
int D = b * b - 4 * a * c;
// Търсим корените на уравнението
if (D > 0)
{
float x1 = (-b + sqrt(D)) / (2 * a);
float x2 = (-b - sqrt(D)) / (2 * a);
cout << "Уравнението има два реални корена: x1 = " << x1 << ", x2 = " << x2 << endl;
}
else
if (D == 0)
{
float x = -b / (2 * a);
cout << "Уравнението има един реален корен: x = " << x << endl;
}
else
{
cout << "Уравнението няма реални корени." << endl;
}
// Това е да пита дали потребителят желае да продължи
cout << "Желаете ли да продължите? (y/n): ";
cin >> da_produlja_li;
if (da_produlja_li == 'y' || da_produlja_li == 'Y')
{
cout << "Моля, стартирайте програмата отново за ново уравнение." << endl;
}
else
{
cout << "Благодаря, че използвахте програмата!" << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+IC8vINCY0LfQv9C+0LvQt9Cy0LAg0YHQtSDQt9CwINGA0LXRiNCw0LLQsNC90LUg0L3QsCDQutC+0YDQtdC90LgKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKSB7CiAgICBpbnQgYSwgYiwgYzsgLy8g0KLQvtCy0LAg0YHQsCDQv9GA0L7QvNC10L3Qu9C40LLQuNGC0LUg0LfQsCDRgNC10YjQsNCy0LDQvdC1INC90LAg0YPRgNCw0LLQvdC10L3QuNC10YLQvgogICAgY2hhciBkYV9wcm9kdWxqYV9saTsgIC8vINCi0L7QstCwINC1INC/0YDQvtC80LXQvdC70LjQstCwINGBINC60L7Rj9GC0L4g0YnQtSDQvdCw0L/RgNCw0LLQuNC8INC40LfQs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