1、1. 输入三角形的三条边a,b,c 的值,根据其数值,判断能否构成三角形。若能则求出三角形的面积。Private Sub Command1_Click()Dim a As Integer, b As Integer, c As IntegerDim s As Single, area As Singlea = InputBox(“请输入边长 a“)b = InputBox(“请输入边长 b“)c = InputBox(“请输入边长 c“)If a + b c And a + c b And b + c a ThenPrint “能构成三角形“s = (a + b + c) / 2area =
2、Sqr(s * (sa) * (sb) * (s-c )Print “面积为:“; areaElsePrint “不能构成三角形“End If End Sub2. 编一程序:根据上网时间计算上网费用。计算的方法如下:为了鼓励多上网,每月收费最多不超过 100 元。30 元基数 10 h费用每小时 2元 1060 h每小时1.5 元 60 hPrivate Sub Command1_Click()Dim a As Integer, page As Singlea = Val(InputBox(“请输入上网的时长“)If a 0 ThenSelect Case aCase Is 100 Then
3、page = 100Print “您本月共上网“; a; “小时,需交费:“; page; “元“End Sub3. 有一个长阶梯,如果每步跨 2阶最后剩 1 阶,如果每步跨 3 阶最后剩 2 阶,如果每步跨 4 阶最后剩3 阶,如果每步跨 5 阶最后剩 4 阶,如果每步跨 6 阶最后剩 5 阶,只有当如果每步跨 7 阶时恰好走完,问这个阶梯至少有多少阶?Private Sub Command1_Click()Dim a As Integer, i As IntegerDo While Truei = i + 1If i Mod 2 = 1 And i Mod 3 = 2 And i Mod
4、4 = 3 And i Mod 5 = 4 And i Mod 6 = 5 _And i Mod 7 = 0 ThenPrint “该阶梯至少有“; i; “阶 “Exit DoEnd IfLoopEnd Sub4. 一个球从 100 m 高度自由下落,每次落地后反跳回原高度的一半,再落下。求它在第 10 次落地时,共经过多少 m?最后一次反弹高度多少?Private Sub Command1_Click()Dim i As Integer, s As Single, h As Singleh = 10For i = 2 To 10s = s + hh = h / 2s = s + hNext
5、 iPrint “共经过 “; s; “米。最后一次反弹高度为“; hEnd Sub5. 有一根长度为 321m 的钢材料,要将它截取成两种规格的短料,规格 a、b 的长度分别为 17 m 和 27 m,问分隔成 a、b 各多少段后,剩余的残料 r 最少?Private Sub Command1_Click()Dim i As Integer, r As Integer, a As Integer, b As Integer, min As Integermin = 17For i = 0 To 11r = (321 - 27 * i) Mod 17If r Max Then Max = fI
6、f f “Y“x = InputBox(“请输入相加的值“)If Val(x) = x Thens = s + xEnd Ifbz = InputBox(“是否结束?(Y/N)“)LoopPrint sEnd Sub19. 求公式:e=1+1/1!+1/2!+1/3!+1/n! 直到n=20 时的 e 值。Private Sub Command1_Click()Dim i As Integer, j As IntegerDim s As Single, h As Single, l As Single, k!k = 1s = 1For i = 1 To 20k = k * is = s + 1
7、 / kNext iPrint sEnd Sub20. 已知 sin(x)=x/1-x3/3!+x5/5!-x7/7!+,设计一个程序,输入 x,通过累加所有绝对值大于等于 0.000001 的项来计算sin(x)的值。Private Sub Command1_Click()Dim i As Integer, j As IntegerDim x As Single, sum As SingleDim h As Single, k As Singlex = InputBox(“请输入 x 的值“)h = 1k = 1Doi = i + 1h = h * xk = k * iIf i Mod 2 = 1 Thenj = j + 1sum = sum + (-1) (j + 1) * h / kEnd IfLoop While Abs(h / k) 10 (-6)Print sumEnd Sub