红色部分系统提示有语法错误请问错在哪
/* 标准文档模板 */
#include "Stdio.h"
#include "Conio.h"
# include<math.h>
float x1,x2,disc,p,q;
greater-than-zero(float a,float b)
{
x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc)/(2*a);
}
equal-to-zero(float a,float b)
{
x1=x2=(-b)/(2*a);
}
smaller-than-zero(float a,float b)
{
p=-b/(2*a);
q=sqrt(disc)/(2*a);
}
main()
{
float a,b,c;
printf("\n input a,b,c:");
scanf("%f,%f,%f",&a,&b,&c);
disc=b*b-4*a*c;
printf("root:\n");
if(disc>0)
{
greater-than-zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n",x1,x2);
}
else if(disc==0)
{equal-to-zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n",x1,x2);
}
else
{smaller-than-zero(a,b);
printf("x1=%5.2f\t x2=%5.2f\n",x1,x2);
}
getch();
}greater-than-zero(float a,float b)
红色部分系统提示有语法错误
请问错在哪
----------------解决方案--------------------------------------------------------
函数名称中不可以使用“-”
----------------解决方案--------------------------------------------------------
改成下划线,应该可以的!
----------------解决方案--------------------------------------------------------
以下是引用yuki在2005-4-17 20:47:14的发言:
函数名称中不可以使用“-”
----------------解决方案--------------------------------------------------------
你好好去看看c语言中是怎么定义变量的。你怎么犯这样的错误....
----------------解决方案--------------------------------------------------------
谢谢!!!
#include "Stdio.h"
#include "Conio.h"
# include<math.h>
float x1,x2,disc;
greater_than_zero(float a,float b)
{
x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
}
equal_to_zero(float a,float b)
{
x1=x2=(-b)/(2*a);
}
main()
{
float a,b,c;
printf("\n input a,b,c:\n");
scanf("%f%f%f", &a,&b,&c);
disc=b*b-4*a*c;
printf("root:\n");
if(disc>0)
{
greater_than_zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n",x1,x2);
}
else if(disc==0)
{equal_to_zero(a,b);
printf("x1=%5.2f\tx2=%5.2f\n",x1,x2);
}
else
printf("NO ROOT");
getch();
}
[此贴子已经被作者于2005-4-19 20:00:15编辑过]
----------------解决方案--------------------------------------------------------