// cbai11.cpp : Defines the entry point for the console application.
//
#include"stdafx.h"
#include<conio.h>
#include<stdio.h>
#include<math.h>
voidgaiptb2(float a,floatb,float c)
{
floatdenta;
printf("\nGiai phuong trinh he so: a= %5.2f, b=%5.2f, c=%5.2f",a,b,c);
if(a==0&&b==0&&c==0) printf("\nPhuong trinh vo so nghiem");
else
if(a==0&&b==0&&c!=0) printf("\nPhuong trinh vo nghiem");
else
if(a==0&&b!=0) printf("\nPhuong trinh co ngiem %f",(-c)/b);
else
if(a!=0)
{
denta=b*b-4*a*c;
if (denta<0) printf("\nPhuong trinh vo nghiem");
if (denta==0) printf("\nPhuong trinh co nghiem kep x1=x2=%f",(-b)/(2*a));
if (denta>0) printf("\nPhuong trinh co 2 nghiem phan biet: x1 = %f, x2 = %f",(-b-sqrt(denta))/(2*a),(-b+sqrt(denta))/(2*a));
}
}
int_tmain(int argc, _TCHAR* argv[])
{
floata,b,c;
printf("\nNhap he so a,b,c: ");
scanf("%f%f%f",&a,&b,&c);
gaiptb2(a,b,c);
getch();
return0;
}
No comments:
Post a Comment