Android
- 1 ответ
- 0 вопросов
1
Вклад в тег
#include <iostream>
#include <stdexcept>
double func(double a, double b, double c)
{
double d = b * b - 4 * a * c;
if (d < 0) {
throw std::runtime_error("d < 0");
}
return d;
}
int main()
{
double a = 1.0;
double b = 2.0;
double c = 3.0;
double d;
try {
d = func(a, b, c);
std::cout << "d = " << d << "\n";
} catch (const std::exception& e) {
std::cout << "ERROR: " << e.what() << "\n";
}
std::cout << "Press any key...";
std::cin.get();
}