-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1131.cpp
More file actions
30 lines (24 loc) · 711 Bytes
/
Copy path1131.cpp
File metadata and controls
30 lines (24 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<stdio.h>
#include<math.h>
void function(double a,double b,double c);
/*------------------------------------------------*/
int main() {
double a, b, c;
while ( scanf("%lf%lf%lf", &a, &b, &c) != EOF) {
function(a, b, c);
}
return 0;
}
/*------------------------------------------------*/
void function(double a,double b,double c) {
double x1, x2;
if ( pow(b, 2) - 4 * a * c > 0 ) {
x1 = (- b + sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);
x2 = (- b - sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);
}
if ( pow(b, 2) - 4 * a * c == 0 ) {
x1 = (- b) / (2 * a);
x2 = x1;
}
printf("%.2f %.2f\n", x1, x2);
}