#include <math.h>
#include <stdio.h>
int main()
{
double area,a,b,c,s;
char ch;
ch='y';
while(ch=='y'||ch=='Y')
{
s=0;
printf("请输入a,c:\n");
scanf("%lf%lf%lf",&a,&b,&c);
if(a+b<=c||b+c<=a||a+c<=b)
{
printf("输入错误,是否重新输入?(是输入Y,否输入N。)");
scanf("%c",&ch);
}
else
{
s=(a+b+c)/2.0;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("面积是%f。\n",area);
printf("输入错误,是否重新输入?(是输入Y,否输入N。)");
scanf("%c",&ch);
}
}
getchar();
}
VB:
dim a as double,b as double,c as double
a=text1.text
b=text2.text
c=text3.text
if a+b>c and b+c>a and a+c>b then
s=(a+b+c)/2
area=sqr(s*(s-a)*(s-b)*(s-c))
label1.caption="三角形面积是:" & area & "。"
else
label1.caption="请重新输入。"
text1.text=""
text1.setfocus
text2.text=""
text3.text=""
end if
原文链接:/vb/259305.html