这是一部很精准的答案!!!希望能帮到你 !!!!
double a,b,c,d,det,a_2,real,imag,x1,x2;
printf("Please enter a,b,c:");
scanf("%lf%lf%lf",&a,&b,&c);
if(a==0&&b==0)
printf("No root!\n");
else if(a==0)
printf("Line equation root is %.2lf\n",-c/b);
else
{
d=b*b-4*a*c;
det=sqrt(fabs(d));
a_2=2*a;
if(d<0)
{
real=-b/a_2;
imag=det/a_2;
printf("The two root are:\n%.2lf+%.2lfi\n",real,imag); printf("and\n%.2lf-%.2lfi\n",real,imag);
}
else if(d==0)
printf("Single real root is %.2lf:\n",-b/a_2);
else
{
x1=-b/(a_2)+det/a_2;
x2=-b/(a_2)+det/a_2;
printf("The two real roots are :\n%.2lf\n
and\n %.2lf\n",x1,x2);
}
}
}
(2)
#include
main()
{
int i,j;
for(i=1;i<=9;i++)
{
for(j=1;j<=9;j++)
printf("%d*%d=%2d ",i,j,i*j);
printf("\n");
}