当前位置: 高中信息技术 / 综合题
  • 1. (2023高一上·镇雄期末) 星期天,小龙来到动物园游玩,园内共有N个景点(可在10个以上),每个景点都有一个标号,标号为1至N。现在只知道每个景点有一条路连接下一个景点。小龙想知道,根据这些道路信息,从其中一个景点出发,最后再回到出发景点,最多能游玩多少个景点。

    例如,共有N=5个景点,每个景点连接的下一个景点分别是2,4,5,5,2。

    景点号

    1

    2

    3

    4

    5

    下一景点号

    2

    4

    5

    5

    2

    则他可以从2号景点出发,最多可以游玩2号、4号、5号三个景点。

    程序代码如下:

    Private Sub Command1_Click()Dim a(1 To 100) As Integer, d(1 To 100) As Integer

        Dim jd As String, m As String, c As Integer, i As Integer

        Dim s As Integer, p As Integer, k As Integer, ans As Integer

        jd = Text1.Text + ","

        s = 0: c = 0

        For i = 1 To Len(jd)

            m = Mid(jd, i, 1)

            If m <> "," Then

                   ①    

            Else

                c = c + 1: a(c) = s: s = 0

            End If

        Next i

        ans = 0: k = 0

        For i = 1 To c

            For k = 1 To c

                d(k) = 0

            Next k

            If d(i) = 0 Then

                p = i

                Do While p <= c

                    If d(p) = 0 Then

                        k = k + 1: d(p) = k

                    Else

                                       

                    If y > ans Then ans = y

                        k = 0

                        Exit Do

                    End If

                   

                Loop

            End If

        Next i

        Text2.Text = Str(ans)

    End Sub

    1. (1) 要使程序运行时,Form1的BackColor属性值为黑色,以下代码正确的是(单选,填字母)。

      A .Private Sub Form_Load()Form1. BackColor = RGB(255, 255,255)

      End Sub

      B .Private Sub Form_Load()Form1.BackColor = RGB(0, 0, 0)

      End Sub

      C .Private Sub Form1_Load()orm1.BackColor = RGB(255,255,255)

      End Sub

      D .Private Sub Form1_Load()Form1.BackColor = RGB(0, 0, 0)

      End Sub

    2. (2) 若有7个景点,且每个景点的连接情况为:6,3,7,2,7,5,4,那么小龙最多可以游玩的景点数是
    3. (3) 请把划线处的代码补充完整:

    4. (4) 程序加框处代码有错,请改正:

微信扫码预览、分享更方便