写了个二元一次方程的代码,在WINTC上编译运行输入完自动弹出,不能产生结果,请高手指点啊!
代码如下,可以靠到您的WINTC上试试#include "Stdio.h"
#include "Conio.h"
#include "math.h"
void main(void)
{
int a;
int b;
int c;
float v;
float delta(int a , int b , int c);
float OneRoot(int a , int b , int c);
float TwoRoot1(int a , int b, int c);
float TwoRoot2(int a , int b, int c);
scanf("%f,%f,%f",&a,&b,&c);
v=delta(a,b,c);
if(v<0)
{
printf("This Equation has no root");
}
else if(v==0)
{
float x;
x=OneRoot(a,b,c);
printf("The only root is %f",x);
}
else if(v>0)
{
float x1,x2;
x1=TwoRoot1(a,b,c);
x2=TwoRoot2(a,b,c);
printf("The two root is x1=%f,x2=%f",x1,x2);
}
getch();
}
float delta(int a , int b , int c)
{
float m;
m=b*b-4*a*c;
return m;
}
float OneRoot(int a , int b, int c)
{
float x;
int w = a*2;
x=(-b)/w;
c=c;
return x;
}
float TwoRoot1(int a , int b ,int c )
{
float x1,d;
int w = a*2;
d=delta(a,b,c);
x1=(-b-sqrt(d))/w;
return x1;
}
float TwoRoot2(int a , int b, int c )
{
float x2,d;
d=delta(a,b,c);
x2=(-b+sqrt(d))/(2*a);
return x2;
}
getch();