Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <assert.h>
- double f(double x)
- {
- if (!(-7 <= x && x <= 7))
- return nan("");
- if (x < 2) {
- if (x <= -2)
- return -0.8 * (7 + x);
- else
- return -4 - sqrt((2 - x) * (2 + x));
- } else {
- if (x <= 5)
- return -4.0;
- else
- return 3 * (x - 6) - 1;
- }
- }
- int main()
- {
- double x = 0;
- int st = scanf("%lf", &x);
- assert (st == 1);
- double y = f(x);
- printf("f(%.16f) = %.16f\n", x, y);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement