三九宝宝网宝宝教育教学论文

输入一个四位正整数编写程序将其逆序输出

02月12日 编辑 39baobao.com

第一个

Private Sub Form_Click()

Dim a As Integer

Dim b(3) As Integer

a = Val(InputBox("输入一个4位数"))

If a > 1000 And a < 10000 Then

For i = 3 To 0 Step -1

b(i) = a / 10 ^ i

a = a - b(i) * 10 ^ i

Next

Else

MsgBox "请输入一个四位数"

Exit Sub

End If

For i = 0 To 3

Print Format(b(i));

Next

End Sub

第二个

Private Sub Form_Click()

Dim a, b, c, d As Integer

c = Val(InputBox("开始数")) '开始数

d = Val(InputBox("结束数")) '结束数

If c > d Then t = c: c = d: d = t

For a = c To d

Sum = 0

For b = 1 To a / 2

If a Mod b = 0 Then Sum = Sum + b

Next b

If Sum = a Then Print Sum

Next a

End Sub

1-1000么就这样

第二个

Private Sub Form_Click()

For a = 1 To 1000

Sum = 0

For b = 1 To a / 2

If a Mod b = 0 Then Sum = Sum + b

Next b

If Sum = a Then Print Sum

Next a

End Sub

推荐阅读
图文推荐