# 最最初级的程序大家帮我指出毛病。谢谢。QQ：13628198

z4b 2005-11-17 06:25:42
/*
*【例4.14】输入三角形的三边长，求三角形面积。
*

*/

#include <stdio.h>
#include <math.h>
int main()
{
float fSideA;
float fSideB;
float fSideC;
float fPerimeter;
double dArea;

scanf("%f,%f,%f", &fSideA, &fSideB, &fSideC);

fPerimeter = ( 1/2 ) * ( fSideA + fSideB + fSideC );
dArea = sqrt( fPerimeter * (fPerimeter-fSideA) * (fPerimeter-fSideB) * (fPerimeter-fSideC) );
printf("%7.2f, %7.2f, %7.2f\n", fSideA, fSideB, fSideC);
printf("%f \n",fPerimeter);
printf("the Area of Triangle is %7.2f \n", dArea);
return 0;
}

...全文
50 点赞 收藏 3

3 条回复

wuwen19 2005-11-17
scanf("%f%f%f", &fSideA, &fSideB, &fSideC);

seabreeze9802 2005-11-17

3,4,5

SereinLi 2005-11-17

#include <stdio.h>
#include <math.h>
int main()
{
float fSideA;
float fSideB;
float fSideC;
float fPerimeter;
double dArea;

scanf("%f,%f,%f", &fSideA, &fSideB, &fSideC);
printf("fSideA = %7.2f, fSideB = %7.2f, fSideC = %7.2f\n", fSideA, fSideB, fSideC);
fPerimeter = ( 1.0/2 ) * ( fSideA + fSideB + fSideC );
printf("fPerimeter = %f \n",fPerimeter);
dArea = sqrt( fPerimeter * (fPerimeter-fSideA) * (fPerimeter-fSideB) * (fPerimeter-fSideC) );
printf("the Area of Triangle is %7.2f \n", dArea);
return 0;
}

C语言

6.4w+

C语言相关问题讨论

2005-11-17 06:25