云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > VB资料之家 计算机二级考试一扫空(36)

VB资料之家 计算机二级考试一扫空(36)

  • 62 次阅读
  • 3 次下载
  • 2025/6/3 19:33:14

9.3 数组应用例题(根据时间可以选择一个讲!) 根据需要,选择1-2道下面的题目,给学生讲清楚算法的思想!

1 排序

例5-3 选择排序法 直接排序法

Option Explicit

Option Base 1

Private Sub CmdSort_Click()

Dim Sort(10) As Integer, Temp As Integer Dim I As Integer, J As Integer Randomize For I = 1 To 10

Sort(I) = Int(Rnd * (100 - 1)) + 1 Text1 = Text1 & Str(Sort(I)) Next I

For I = 1 To 9

For J = I + 1 To 10

If Sort(I) > Sort(J) Then Temp = Sort(I) Sort(I) = Sort(J) Sort(J) = Temp

End If Next J

Text2 = Text2 & Str(Sort(I)) Next I

Text2 = Text2 & Str(Sort(10)) End Sub

Option Explicit Option Base 1

Private Sub CmdSort_Click()

Dim Sort(10) As Integer, Temp As Integer Dim I As Integer, J As Integer Dim Pointer As Integer Randomize For I = 1 To 10

Sort(I) = Int(Rnd * (100 - 1)) + 1 Text1 = Text1 & Str(Sort(I)) Next I

For I = 1 To 9 Pointer = I

For J = I + 1 To 10

If Sort(Pointer) > Sort(J) Then Pointer = J End If Next J

If I <> Pointer Then Temp = Sort(I) Sort(I) = Sort(Pointer) Sort(Pointer) = Temp End If

Text2 = Text2 & Str(Sort(I)) Next I

Text2 = Text2 & Str(Sort(10))

End Sub

2 查找

例:5-4 顺序查找程序 (界面见P105) 先介绍For Each –next 结构的语句: Option Explicit

Option Base 1 Dim Search As Variant

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

9.3 数组应用例题(根据时间可以选择一个讲!) 根据需要,选择1-2道下面的题目,给学生讲清楚算法的思想! 1 排序 例5-3 选择排序法 直接排序法 Option Explicit Option Base 1 Private Sub CmdSort_Click() Dim Sort(10) As Integer, Temp As Integer Dim I As Integer, J As Integer Randomize For I = 1 To 10 Sort(I) = Int(Rnd * (100 - 1)) + 1

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com