C方程根
我刚接触C语言,请高人指点一下我的错误。#include<stdio.h>
main()
{
int a,b,c;
float x,x1,x2,disc,p;
printf("please input a,b,c:");
scanf("%d%d%d",&a,&b,&c);
if(a==0) {if(b==0) printf("error");else printf("x=%f.2",-c/b);}
else { disc=b*b-4*a*c;p=2*a;
if(disc>0) printf("x1=%.2f,x2=%.2f",(-b-sqrt(p))\p,(-b+sqrt(p)/p);
else if(disc==0) printf("x1=x2=%.2f",-b/p);
else printf("方程有两复根");}
}