搜索
您的当前位置:首页正文

变变变

2020-06-27 来源:步旅网


ReDim a(1 To n + 1)

Randomize

For i = 1 To n

a(i) = Int(Rnd() * 100 + 1)

Print a(i);

If i Mod 10 = 0 Then

Print

End If

Next i

Print

p = Val(InputBox(\"请输入要查找的值\"))

For i = 1 To n

If (p = a(i)) Then

Print \"查到了在第\"; i; \"位\"

s = s - 1

x = x + 1

If i <= n Then

For j = i To n

a(j) = a(j + 1)

Next j

For j = 1 To n - x

Print a(j);

If j Mod 10 = 0 Then

Print

End If

Next j

End If

End If

Print

Next i

If i > n Then

Print \"\"

For i = 1 To n

flag = 1

For j = 1 To n - i

If a(j) > a(j + 1) Then

t = a(j)

a(j) = a(j + 1)

a(j + 1) = t

flag = 0

End If

Next j

If flag = 1 Then

Exit For

End If

Next i

Print \"*******排序后******\"

For i = 1 To n

Print a(i);

If i Mod 10 = 0 Then

Print

End If

Next i

Print

For k = 1 To n

If p < a(k) Then Exit For

Next k

For i = n To k Step -1

a(i + 1) = a(i)

Next i

a(k) = p

Print \"******插入后******\"

For i = 1 To n + 1

Print a(i);

If i Mod 10 = 0 Then

Print

End If

Next i

End If

End Sub

因篇幅问题不能全部显示,请点此查看更多更全内容

Top