-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.cpp
58 lines (49 loc) · 1.1 KB
/
1.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <cstdio>
#include <math.h>
double f(double x, double a, double b, double c);
int main(void)
{
double a = 1e-17;
double b = -1e17;
double c = 1e17;
double x;
double x1; double x2; double x11; double x22;
if(a!=0)
{
x11 = b+(sqrt(pow(b,2)-4*a*c));
x1 = (-2*c)/x11;
x22 = b-(sqrt(pow(b,2)-4*a*c));
x2 = (-2*c)/x22;
std::printf("La raiz positiva es = %.16f\n", x1);
std::printf("La raiz negativa es = %.16f\n", x2);
std::printf("f(%.16f) = %f\n",x1,f(x1,a,b,c));
std::printf("f(%.16f) = %f\n",x2,f(x2,a,b,c));
}
else
{
if(b!=0)
{
x1 = -c/b;
std::printf("La raiz es = %f\n", x1);
std::printf("f(%f) = %f\n",x1,f(x1,a,b,c));
}
else
{
if(c==0)
{
std:: printf("x puede ser cualquier numero ya que f(x) = %f\n", f(x,a,b,c));
}
else
{
std:: printf("La ecuacion no tiene solucion ya que f(x) = %f\n", f(x,a,b,c));
}
}
}
return 0;
}
double f(double x, double a, double b,double c)
{
double f;
f = a * (pow(x,2)) + b * x + c;
return f;
}