完整的VB 程序怎么 写
计算三角形的 三个边长和面积(a. b . c p=(a+b+c)/2 s=根号下p(p-a)*(p-b)*(p-c) VB程序怎么 做?
答案:5 悬赏:10 手机版
解决时间 2021-05-10 01:08
- 提问者网友:你给我的爱
- 2021-05-09 14:54
最佳答案
- 五星知识达人网友:毛毛
- 2021-05-09 15:41
Private Sub Command1_Click()
Dim a As Double, b As Double, c As Double
a = val(text1.text)
b = val(text2.text)
c = val(text3.text)
If a + b < c Or a + c < b Or b + c < a Then
MsgBox "不能构成三角形!"
Exit Sub
End If
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
MsgBox "三角形的面积是:" & Format(s, ".00")
End Sub
Dim a As Double, b As Double, c As Double
a = val(text1.text)
b = val(text2.text)
c = val(text3.text)
If a + b < c Or a + c < b Or b + c < a Then
MsgBox "不能构成三角形!"
Exit Sub
End If
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
MsgBox "三角形的面积是:" & Format(s, ".00")
End Sub
全部回答
- 1楼网友:迟山
- 2021-05-09 18:33
p=(a+b+c)/2 这个可以直接就这么写
s=根号下p(p-a)*(p-b)*(p-c) 写成
s=(p(p-a)*(p-b)*(p-c) )^0.5
就可以了
完整代码
Private Sub Command3_Click() Dim a As Double Dim b As Double Dim c As Double Dim p As Double Dim s As Double a = InputBox("请输入A的值", "输入", "") b = InputBox("请输入B的值", "输入", "") c = InputBox("请输入c的值", "输入", "") p = (a + b + c) / 2 s = (p * (p - a) * (p - b) * (p - c)) ^ 0.5 Print p, s
End Sub
- 2楼网友:鸽屿
- 2021-05-09 17:56
楼上回答很清楚!Private Sub Command1_Click()
If a + b < c Or a + c < b Or b + c < a Then
MsgBox "不能构成三角形!请重新输入"
Exit Sub
End If
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
MsgBox "三角形的面积是:" & Format(s, ".00")
End Sub
还要补充??规则有问题,我投的是赞成票!!!!
- 3楼网友:上分大魔王
- 2021-05-09 16:50
#include<stdio.h>
#include<math.h>
int main()
{
double a,b,c,s,p;
printf("input a,b,c: ");
scanf("%lf,%lf,%lf",&a,&b,&c);
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
printf("三角形周长 %lf ,面积 %lf 。",p,s);
getch();
return 0;
}
- 4楼网友:西风乍起
- 2021-05-09 16:34
Private Sub Command1_Click()
Dim a As Double, b As Double, c As Double
a = CDbl(InputBox("请输入三角形的第一边a:"))
b = CDbl(InputBox("请输入三角形的第一边b:"))
c = CDbl(InputBox("请输入三角形的第一边c:"))
If a + b < c Or a + c < b Or b + c < a Then
MsgBox "不能构成三角形!"
Exit Sub
End If
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
MsgBox "三角形的面积是:" & Format(s, ".00")
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯