久久京东热成人精品视频,伊人久久综合,国产一区二区精品自拍,在线精品国精品国产3d

<menu id="e206k"></menu>
<center id="e206k"></center>
  • <menu id="e206k"></menu>
    <center id="e206k"></center>
  • <menu id="e206k"><noscript id="e206k"></noscript></menu>
    當(dāng)前位置: 高中信息技術(shù) / 綜合題
    • 1. (2023高一下·香格里拉月考) 對一個n×n的矩陣以“行”為單位進(jìn)行升序排序,如下表所示是一個4×4的矩陣以行為單位進(jìn)行升序排序。

      李華編寫了實現(xiàn)上述功能的程序,程序功能如下:程序運行時,在文本框Text1中輸入n(1<=n<=10)單擊“產(chǎn)生”按鈕Command1產(chǎn)生n×n個隨機(jī)數(shù),隨機(jī)數(shù)的范圍為[0,9],隨機(jī)存儲在數(shù)組a中,并以矩陣的形式在列表框List1上顯示。單擊“排序”按鈕Command2,對矩陣以“行”為單位進(jìn)行升序排序,并在列表框List2輸出排序后的矩陣。在程序運行界面如下圖所示。

      實現(xiàn)上述功能的VB程序如下,請在劃線處填入合適的代碼。

      Dim n As Integer

      Dim a(1 To 100) As Integer

      Private Sub Command1_Click( )

          Dim i As Integer, s As String

          s = ""

         

          For i = 1 To n * n

              

              s = s + Str(a(i))

              If i Mod n = 0 Then

                  List1.AddItem s

                  s = ""

              End If

          Next i

      End Sub

      Private Sub Command2_Click()

          Dim i As Integer, j As Integer, t As Integer

          Dim s As String

          s = ""

          For i = 1 To n * n

              k = i

              For j = i + 1 To

                  If a(j) < a(k) Then k = j

              Next j

              If k <> i Then t = a(k):a(k) = a(i):a(i) = t

             

              If i Mod n = 0 Then

                  List2.AddItem s

                  s = ""

              End If

          Next i

      End Sub

    微信掃碼預(yù)覽、分享更方便