没有合适的资源?快使用搜索试试~ 我知道了~
VB常用算法代码.doc
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 184 浏览量
2021-10-08
22:03:30
上传
评论
收藏 76KB DOC 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/29762613/0001-89eb674588b5f32334aaabc102f82efa_thumbnail-wide.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
24页
VB常用算法代码.doc
资源推荐
资源详情
资源评论
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![tar](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/release/download_crawler_static/29762613/bg1.jpg)
- .
Feb 数列前 18 项
Option Base 1
Private Sub Form_Click()
Dim Feb(18) As Integer, I As Integer
Feb(1) = 1
Feb(2) = 1
For I = 3 To 18
Feb(I) = Feb(I - 1) + Feb(I - 2)
Next
For I = 1 To 18
Print Feb(I),
If I Mod 5 = 0 Then Print
Next
End Sub
鞍点
Option Explicit
Option Base 1
Private Sub Form_Click()
Cls
Dim A(4, 5) As Integer, I As Integer, J As Integer, K As Integer
Dim Max As Integer, Min As Integer
Dim Row As Integer, Col As Integer, Flag As Boolean
Randomize
For I = 1 To 4
For J = 1 To 5
A(I, J) = Rnd * 90 + 10
Print A(I, J);
Next
Print
Next
I = 1
Flag = False
Do While I <= 4
Max = A(I, 1)
Row = I
Col = 1
For J = 2 To 5
If Max < A(I, J) Then
Max = A(I, J)
Row = I
Col = J
End If
- .word.zl.
![](https://csdnimg.cn/release/download_crawler_static/29762613/bg2.jpg)
- .
Next
Min = Max
For K = 1 To 4
If Min > A(K, Col) Then
I = I + 1
Flag = False
Exit For
End If
Next
If K = 5 Then
Flag = True
Exit Do
End If
Loop
If Not Flag Then Print " 鞍点不存在! " Else Print "鞍点的位置:" & CStr(Row) &
"行" & CStr(Col) & "列"
End Sub
插入排序
Option Base 1
Private Sub mand1_Click()
Dim A(10) As Integer, I As Integer, J As Integer, X As Integer
Cls
Print "排序前:";
For I = 1 To 10
A(I) = Int(100 * Rnd)
Print A(I);
Next
Print
For J = 2 To 10
X = A(J)
I = J - 1
Do While X < A(I)
A(I + 1) = A(I)
I = I - 1
If I < 1 Then Exit Do
Loop
A(I + 1) = X
Next
Print "排序后:";
For I = 1 To 10
Print A(I);
Next
End Sub
- .word.zl.
![](https://csdnimg.cn/release/download_crawler_static/29762613/bg3.jpg)
- .
二分插入排序
Option Base 1
Private Sub mand1_Click()
'二分插入排序
Dim A(10) As Integer, I As Integer, J As Integer, X As Integer
Cls
Print "排序前:";
For I = 1 To 10
A(I) = Int(100 * Rnd)
Print A(I);
Next
Print
Dim First As Integer, Last As Integer, Middle As Integer
Dim K As Integer
For J = 2 To 10
X = A(J)
First = 1
Last = J - 1
Do While First <= Last
Middle = (First + Last) / 2
If X > A(Middle) Then
Last = Middle - 1
Else
First = Middle + 1
End If
Loop
For K = J - 1 To Middle Step -1
A(K + 1) = A(K)
Next
A(Middle) = X
Next
Print "排序后:";
For I = 1 To 10
Print A(I);
Next
End Sub
插入一个数到有序数列
Dim A(10) As Integer, I As Integer, J As Integer
Private Sub mand1_Click()
Dim X As Integer
- .word.zl.
![](https://csdnimg.cn/release/download_crawler_static/29762613/bg4.jpg)
- .
X = Text1.Text
I = 9
Do While X < A(I)
A(I + 1) = A(I)
I = I - 1
Loop
A(I + 1) = X
Print "插入数后:";
For I = 0 To 10
Print A(I);
Next
Print
End Sub
Private Sub mand2_Click()
Dim temp As Integer
Cls
For I = 0 To 9
A(I) = Int(100 * Rnd)
Next
For I = 0 To 8
For J = I + 1 To 9
If A(I) > A(J) Then
temp = A(I)
A(I) = A(J)
A(J) = temp
End If
Next
Next
Print "有序序列:";
For I = 0 To 9
Print A(I);
Next
Print
Text1.SetFocus
End Sub
Private Sub Form_Activate()
Print "将一个数插入到一个有序的序列中!"
End Sub
查找子串位置
Option Base 1
- .word.zl.
![](https://csdnimg.cn/release/download_crawler_static/29762613/bg5.jpg)
- .
Private Sub mand1_Click()
Dim S1 As String, S2 As String
S1 = Text1.Text
S2 = Text2.Text
Text3.Text = Index(S1, S2)
End Sub
Public Function Index(S As String, T As String) As Integer
Dim I As Integer, J As Integer
Dim LenS As Integer, LenT As Integer
LenS = LenB(S)
LenT = LenB(T)
I = 1: J = 1
Do While I <= LenS And J <= LenT
If MidB(S, I, 1) = MidB(T, J, 1) Then
I = I + 1
J = J + 1
Else
I = I - J + 2
J = 1
End If
Loop
If J > LenT Then Index = I - LenT Else Index = 0
End Function
自动出题
Option Explicit
Public A As Integer, B As Integer, Opt As String
Public Correct As Integer, Wrong As Integer
Private Sub mand1_Click()
Randomize
Dim C As Integer
Text1.Text = ""
A = Int(10 * Rnd) + 1
B = Int(10 * Rnd) + 1
C = Int(4 * Rnd)
Select Case C
Case 0: Opt = "+"
Case 1: Opt = "-"
Case 2: Opt = "*"
- .word.zl.
剩余23页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
wdqsv88
- 粉丝: 4
- 资源: 13万+
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)