• 2021-04-14
    编写子过程,子过程的功能是:交换一个数组中最大值和最小值的位置,其他元素的位置不变。要求在主调过程中输入(或随机产生)一组数,并在主调过程中输出处理前、处理后的数据。
    Private Sub Form_Click()
    Dim a%(1 To 10), i%
    Print "原始数据:"
    For i = 1 To 10
    a(i) = Int( 【1】* 101 + 100)
    Print a(i);
    Next i
    Print
    Call 【2】
    Print "交换后:"
    For i = 1 To 10
    Print a(i);
    Next i
    Print
    End Sub
    Sub jh(b%())
    Dim ma%, mi%, i%, t%
    ma = LBound(b)
    mi = LBound(b)
    For i = LBound(b) + 1 To 【3】
    If 【4】Then ma = i
    If b(mi) > b(i) Then 【5】
    Next i
    t = b(ma): b(ma) = b(mi): b(mi) = 【6】
    End Sub

  • Rnd;Rnd() --- jh(a) --- UBound(b) --- b(ma) < b(i) --- mi = i --- t

    内容

    • 0

      Public Sub Proc(a%( )) Static i% Do a(i) = a(i) + a(i + 1) i = i + 1 Loop While i < 2 End Sub Private Sub Command1_Click( ) Dim m%, i%, x%(10) For i = 0 To 4: x(i) = i + 1:  Next i For i = 1 To 2: Call Proc(x):    Next i For i = 0 To 4: Print x(i);:    Next i End Sub A: 3 4 7 5 6 B: 3 5 7 4 5 C: 2 3 4 4 5 D: 4 5 6 7 8

    • 1

      阅读程序: Option Base 1 Sub P(b() As Integer) For i=1 To 4 b(i)=2*i Next i End Sub Private Sub Form_Click() Dim a(4)As Integer For i=1 To 4 a(i)=i+4 Next i P a For i=1 To 4 Print a(i) Next i End Sub 运行上面的程序,单击窗体,输出结果为 A: 2 4 6 8 B: 5 6 7 8 C: 10 12 14 16 D: 4 8 12 16

    • 2

      下列程序: Option Base 1 Private Sub Form_Click() Dim a(5,5) For i = 1 To 5 For j = 1 To 5 k = k + 1 a (i,j)= k Next j Next i For i = 1 To 5 s = s + a (i,i) Next i Print s End Sub 运行时的输出结果是( )。

    • 3

      下列程序的运行结果为( )。 Private Sub Command1_Click() Dim a(5) As String Dim i As Integer For i = 0 To 5 a(i) = i + 1 Print a(i); Next i End Sub

    • 4

      下列程序运行后输出结果是_______. Private Sub Form_Click() K=1 For I=5 to 1 step -1 T=T*10 + K S=S+T Next I Print S End sub