新鸟求教 不知道下面的程序错在那里
# include <stdio.h># include <math.h>
int main(void)
{
//把三个系数保存到计算机中
int a = 1; //=不表示相等,表示赋值
int b = 2;
int c = 3;
double delta; //delt存放的是 b*b - 4*a*c
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");
}
}
Compiling...
Cpp3.cpp
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(14) : error C2018: unknown character '0xa3'
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(14) : error C2018: unknown character '0xbb'
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(16) : error C2143: syntax error : missing ';' before 'if'
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(30) : error C2018: unknown character '0xa3'
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(30) : error C2018: unknown character '0xbb'
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(31) : error C2143: syntax error : missing ';' before '}'
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(32) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.
Cpp3.exe - 1 error(s), 0 warning(s)