求助:为什么我输入三边(3.0,4.0,5.0)后一直按Enter键,一直转行,不执行?
【用的vs 2019】
#include<stdio.h>#include<math.h>
int main()
{
double triangle_area(double a, double b, double c);
double a, b, c,area=0;
printf("请输入三角形的三条边:");
scanf_s("%lf,%lf,%lf\n", &a, &b, &c);
area = triangle_area(a, b, c);
printf("三角形的面积为:%f", area);
return 0;
}
double triangle_area(double a, double b, double c)
{
double p, s;
p = (a + b + c) / 2;
s = sqrt(p * (p - a) * (p - b) * (p - c));
if (a + b > c && b + c > a && a + c > b)
return (s);
else return (0.0);
}