试题

试题 试卷

logo

题型:综合题 题类:常考题 难易度:普通

浙江省高中信息技术 高精度计算问题练习

大数加法。在文本框Text1和Text2中输入两个大数,点击“相加”按钮后,在文本框Text3中输出结果。

实现上述功能的VB程序如下,请在划线处填入合适的代码。

Private Sub Command1_Click()

Dim s1 As String

Dim s2 As String

Dim s3 As String

Dim l1 As Integer

Dim l2 As Integer

Dim l3 As Integer

Dim a(1 To 100) As Integer

Dim b(1 To 100) As Integer

Dim c(1 To 100) As Integer

Dim t As Integer

s1 = Text1.Text

s2 = Text2.Text

l1 = Len(s1)

l2 = Len(s2)

For i = l1 To 1 Step -1

 a(i) =

Next

For i = l2 To 1 Step -1

 b(i) =Val(Mid(s2, l2 - i + 1, 1))

Next

If l1 > l2 Then l3 = l1 Else l3 = l2

t = 0

For i = 1 To l3

  c(i) = a(i) + b(i) + t

  t = c(i) \ 10

  c(i) =

Next

For i = 1 To l3

  s3 = Str(c(i)) + s3

Next

IfThen s3 = “1” + s3

Text3.Text = s3

End Sub

举一反三
返回首页

试题篮