组卷题库 > 高中信息技术试卷库
试题详情
有如下VB程序段:

Private Sub Command1_Click()

    Dim n As Integer, ans As Integer

    n = 5

    Dim x(1 To 5) As Integer

    x(1) = -30: x(2) = 26: x(3) = -18: x(4) = 60: x(5) = 22

    ans = 60

    For i = 1 To n

        If x(i) < 0 Then x(i) = -x(i)

        ans = ans + gcd(ans, x(i))

    Next i

    Text1.Text = Str(ans)

End Sub

Function gcd(a As Integer, b As Integer)

    If b = 0 Then

        gcd = a

    Else

        gcd = gcd(b, a Mod b)

    End If

End Function

执行该程序段后,Text1. Text中显示的值为(      )

A、1
B、2
C、90
D、98
知识点
参考答案
采纳过本试题的试卷
教育网站链接