A1 #include
double double_parse(const char* prompt) {
double value;
printf("%s", prompt);
scanf("%lf", &value);
while (getchar() != '\n') {;}
return value;
}
double f(double x, double a, double b, double c) {
if (x < 0 && b != 0) return a * x * x - b;
if (x > 0 && b == 0) return (x - a) / (x - b);
return x / c;
}
int main(void) {
double a = double_parse("a: ");
double b = double_parse("b: ");
double c = double_parse("c: ");
double xn = double_parse("Xнач: ");
double xk = double_parse("Xконеч: ");
double dx = double_parse("dx: ");
double end = xk + dx / 10.0;
double x = xn;
while (x < end) {
printf("%5.2lf %12.4lf\n", x, f(x, a, b, c));
x += dx;
}
return 0;
}