# include <stdio.h>
# include <math.h>
int main(void)
{
int a = 1;
int b = 2;
int c = 3;
double delta;
double x1;
double x2;
delta = b*b - 4*a*c;
if (delta > 0)
{
x1 = (-b + sqrt(delta)) / (2*a);
x2 = (-b - sqrt(delta)) / (2*a);
printf(“该一元二次方程有两个解,x1 = %f, x2 = %f\n”, x1, x2);
}
else if (delta == 0)
{
x1 = (-b) / (2*a);
x2 = x1;
printf(“该一元二次方程有唯一解,x1 = x2 = %f\n” , x1);
}
else
{
printf(“无解\n”);
}
return 0;
}
--------------------Configuration: T1 - Win32 Debug--------------------
Compiling...
T1.CPP
L:\程序\T1.CPP(5) : error C2018: unknown character '0xa3'
L:\程序\T1.CPP(5) : error C2018: unknown character '0xfb'
L:\程序\T1.CPP(6) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
L:\程序\T1.CPP(6) : error C2146: syntax error : missing ';' before identifier 'a'
L:\程序\T1.CPP(6) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
T1.OBJ - 1 error(s), 0 warning(s)
程序提醒 int a=1 这一行错误,本人初学C语言,求大神帮助!
把所有的中文符号改为英文的。另外x应该是x2
# include <stdio.h>请问您说的 “另外x应该是x2” 在那一行?
追答上面程序中第17行:
printf("该一元二次方程有两个解,x1 = %f, x2 = %f\n", x1, x2);
我已经帮你改好了。
Debug/欢迎来到C世界.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
请问我在Build该程序时,仍提示有一处错误,求大神帮助。以上错误已改,程序运行后,我会追加30分。
你改过程序了?我给你的是好的,把你的代码再发出来看看?
追问复制的您的代码,但在Build时提示:
Debug/欢迎来到C世界.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
单独这个程序是没有问题的,你是不是项目里面加入了其他c或c++文件,重复定义了main函数?如果有需要可以私信我加QQ我帮你看看