编写的函数为何不能被主函数调用?
在VC6.0中编译,不管a,b,c输入什么值,结果都是显示"it is not triangle!"。好像编写的sabc()函数并未被主函数调用,请大家帮我看看,是怎么回事?
#include "math.h"
#include "stdio.h"
double sabc(double a, double b, double c); /*函数说明*/
main()
{double a, b, c;
double s;
printf("input the length of triangle sides:");
scanf("%lf%lf%lf",&a,&b,&c);
if(a+b<=c||b+c<=a||a+c<=b) /*两边之和大于第三边为三角形成立的条件*/
printf("it is not triangle!\n");
else
s=sabc(a,b,c);
printf("the area is:\n",s);
}
double sabc(double x, double y, double z)
{ double p, s;
p=(x+y+z)/2;
s=sqrt(p*(p-x)*(p-y)*(p-z));
return (s);
}