Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main ()
- {
- FILE *fp, *fo;
- fo = fopen("input.txt","r");
- fp = fopen("output.txt","w");
- double a, b, c, D, x1, x2;
- fscanf(fo, "%lf %lf %lf", &a, &b, &c);
- D = (pow(b, 2) - 4*a*c);
- if (a != 0)
- {
- if (D < 0)
- {
- fprintf(fp, "NO");
- }
- else
- {
- if (D == 0)
- {
- fprintf(fp, "%lg", -b / (2*a));
- }
- else
- {
- x1 = (-b - sqrt(D))/(2 * a);
- x2 = (-b + sqrt(D))/(2 * a);
- if (x1 > x2)
- {
- fprintf(fp, "%lg %lg", x2, x1);
- }
- else
- {
- fprintf(fp, "%lg %lg", x1, x2);
- }
- }
- }
- }
- else
- {
- if (b == 0)
- {
- if (c == 0)
- {
- fprintf(fp, "R");
- }
- else
- {
- fprintf(fp, "NO");
- }
- }
- else
- {
- fprintf(fp, "%lg", -c / b);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement