#include
#include
#include
#include
int gptb2(float a, float b, float c, float* x1, float* x2)
{
float del;
del = b*b - (4*a*c);
if(del < 0) return -1;
else
{
*x1 = (-b - sqrt(del))/ (2*a);
*x2 = (-b + sqrt(del))/ (2*a);
}
return 1;
}
int main()
{
clrscr();
float a, b, c, x1, x2;
printf("\nNhap a, b, c:");
scanf("%f%f%f", &a,&b,&c);
fflush(stdin);
if(a == 0)printf("X = %.2f", -c/b);
else
{
if(gptb2(a,b,c,&x1,&x2) == -1)
printf("\nphuong trinh vo nghiem");
else
{
printf("\nx1 = %.2f", x1);
printf("\nx2 = %.2f", x2);
}
}
getch();
return 0;
}
Giải và biện luận phương trình bậc 2 (tính cả trường hợp suy biến)
ExampleCode
Đăng ký:
Đăng Nhận xét (Atom)
Bình luận lịch sự, vui vẻ không quạo ConversionConversion EmoticonEmoticon