教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 政务民生 >

VB程序设计基础 申石磊 答案(4)

来源:网络收集 时间:2026-08-18
导读: m% = InputBox(\请输入正整数m(m>=1)\阶乘\ n% = InputBox(\请输入正整数n(n>=m)\阶乘\ For m = m To n t = 1 For i = 1 To m t = t * i Next i s = s + t Next m Print \…+n!=\ End Sub 4-13 Private Sub Form_cl

m% = InputBox(\请输入正整数m(m>=1)\阶乘\ n% = InputBox(\请输入正整数n(n>=m)\阶乘\

For m = m To n

t = 1

For i = 1 To m

t = t * i Next i s = s + t Next m

Print \…+n!=\

End Sub

4-13

Private Sub Form_click()

Dim a% Dim b% Dim c% For a = 1 To 20 For b = 1 To 20 For c = 1 To 20

If a * a + b * b = c * c Then

Print a, b, c

End If

Next c Next b Next a End Sub

4-14

Private Sub Form_click()

For n = 1 To 500 For i = 1 To n - 1

If n Mod i = 0 Then s = s + i

Next i

If s = n Then Print i;

s = 0 Next n Print End Sub

4-15

Private Sub Form_click()

Dim i As Integer Dim n As Long

n = 1 t = 1

Do While t > 0.00001

e = e + t i = i + 1 n = n * i t = 1 / n Loop

Print \的近似值是\

End Sub 5—1

Private SubForm_Click() Dim i%, x(1 To 5)As String For i = LBound(x)To UBound(x) x(i) =InputBox(\

Next i

For i = UBound(x)To LBound(x) Step -1

Print x(i) Next i Print

End Sub 5-2

Private Sub Form_Click() Dim i%, s

s = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

For i = 0 To 9

If s(i) Mod 3 = 0 Then Print s(i); i Else Print \ End If Next i Print End Sub 5-3

Option Base 1

Private Sub Command1_Click() Dim x()

x = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) t = x(1)

For i = 1 To 9 x(i) = x(i + 1) Print x(i); Next x(10) = t Print x(i) End Sub

Private Sub Command2_Click() Dim x()

x = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) t = x(10)

For i = 9 To 1 Step -1 x(i + 1) = x(i) Next i x(1) = t

For i = 1 To 10 Print x(i); Next i End Sub 5-4

Private Sub Form_Click() Dim a(5, 5) For i = 1 To 5 Sum = 0 For j = 1 To 5

a(i, j) = Int(Rnd * 51 + 10) Sum = Sum + a(i, j) Print a(i, j); Next j

VB程序设计基础 申石磊 答案(4).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/448465.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)