显示没有问题 但是有两个错误是什么意思呀
#include <stdio.h>#include <math.h>
int main(void)
{
float a;
float b;
float c;
float p;
float area;
printf("请输入程序的三条边长:");
scanf_s("%f,%f,%f",& a, & b,& c);
p = 0.5 * (a + b + c);
area = sprt(p * (p - a) * (p - b) * (p - c));
printf("a=%f,b=%f,c=%f,p=%f\n",a,b,c,p);
printf("area=%f\n", area);
return 0;
}
试试这样:
#include <stdio.h>
#include <math.h>
int main(void)
{
float a;
float b;
float c;
float p;
float area;
printf("请输入程序的三条边长:");
scanf("%f,%f,%f", &a, &b, &c);
p = 0.5 * (a + b + c);
area = sqrt(p * (p - a) * (p - b) * (p - c));
printf("a=%f,b=%f,c=%f,p=%f\n", a, b, c, p);
printf("area=%f\n", area);
return 0;
} 你是不是警告这样:
a.c: In function 'main':
a.c:13:9: warning: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
13 | scanf_s("%f锛锛",& a, & b,& c);
| ^~~~~~~
| scanf
a.c:16:16: warning: implicit declaration of function 'sprt'; did you mean 'sqrt'? [-Wimplicit-function-declaration]
16 | area = sprt(p * (p - a) * (p - b) * (p - c));
| ^~~~
| sqrt
如果是的话,
第一个警告提示你把 scanf_s 换成 scanf,
第二个警告说你sqrt写成了sprt ckblt 发表于 2022-2-19 15:05
你是不是警告这样:
okkkk
页:
[1]