ImageVerifierCode 换一换
格式:DOC , 页数:17 ,大小:19.46KB ,
资源ID:2792972      下载积分:20 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.docduoduo.com/d-2792972.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录   微博登录 

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(vb中一维二维数组应用(Application of one dimension two dimensional array in VB).doc)为本站会员(dzzj200808)主动上传,道客多多仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知道客多多(发送邮件至docduoduo@163.com或直接QQ联系客服),我们立即给予删除!

vb中一维二维数组应用(Application of one dimension two dimensional array in VB).doc

1、vb 中一维二维数组应用(Application of one dimension two dimensional array in VB)One-dimensional arraysortFirst, select sort method:The data has been placed in a one-dimensional array, requiring small to large sorting.arrayTwentyFourThirty-sixForty-fiveOne hundred and nineThreesubscriptOneTwoThreeN-2N-1NSortin

2、g process:1, select the minimum from the first item to the item n, and then exchange the first item with the minimum item.2, select the minimum from the second item to the item n, and then exchange the second item with the minimum item.3,4, select the minimum from item n-1 to item n, and then exchan

3、ge the item n-1 with the minimum.Note: the minimum and subscript are stored by temporary variables.So, you need two layers of loops: the outer loop I executes n-1 times, and the inner loop J executes n-i-1 timesFor i=1 to n-1The minimum and subscript are stored by temporary variablesItem I of item t

4、mpVal=TmpId= item I subscriptFor j=i+1 to nIf tmpVal J, then:Item J of item tmpVal=TmpId= item J subscriptNextExchange item I with the minimum itemNextFrom big to small?Two, bubble sort method:The data has been placed in a one-dimensional array, requiring small to large sorting.arrayTwentyFourThirty

5、-sixForty-fiveOne hundred and nineThreesubscriptOneTwoThreeN-2N-1NTwo methods: decimal floating and large number sinking.Decimal floating sorting process: from item n to item K, there are two comparisons in turn. If the item M is less than item M-1, the two exchange. (K from 2 to n)First execution:

6、the result is the minimum item from item first to item n in the first item1, if item n is less than item n-1, the item n is exchanged with item n-1.2, if item n-1 is less than item n-2, the item n-1 is exchanged with item n-2.3,4, if second items are less than first items, second items will be excha

7、nged with first items.Second execution: the result is the minimum item from item second to item n in the second item1, if item n is less than item n-1, the item n is exchanged with item n-1.2, if item n-1 is less than item n-2, the item n-1 is exchanged with item n-2.3,4, if third items are less tha

8、n second items, third items will be exchanged with second items.N-1 execution:1, if item n is less than item n-1, the item n is exchanged with item n-1.So, you need two layers of loops: the outer loop I executes n-1 times, and the inner loop J executes n-i timesFor i=1 to n-1For j=n to i+1 step -1If

9、 the value of item J is less than item J-1, then:Item J-1 of item tmp=Item J-1 = item JItem J = TMPNextNextThe descending order process of large numbers: from first items to item K, there are two comparisons in turn, and if the item M is greater than item m+1, the two exchanges. (K from n-1 to 1)For

10、 i=n to 2 step -1For j=1 to I-1If the value of item J item j+1, then:Item j+1 of item tmp=Item j+1 = item JItem J = TMPNextNextFrom big to small?lookupFirst, sequential search method:The data is already in the arrayarrayTwentyFourThirty-sixForty-fiveOne hundred and nineThreesubscriptOneTwoThreeN-2N-

11、1NSearch method: compare the number from first items to item N and the number to be searched.For i=1 to nThe number to be searched is equal to the value of item I Equal returns the I value and terminates the loop.NextTwo, the binary search method:The data has already been placed in a one-dimensional

12、 array, requiring that the number in the array has been sorted.ThreeFourTwentyThirty-sixForty-fiveOne hundred and nineOneTwoThreeFourFiveSixSearching method:In comparison with (1+n) 2, if the item is less than that, it is found between items in the subscript interval (1, (1+n) 2-1), otherwise the it

13、ems in the subscript interval (1+n) 2+1, n) are searched.For example, find 45 in the upper table array1, compare (1+6) 2 items, that is, third items, 4520, find between (4, 6).2, the comparison of item (4+6) 2, that is, fifth items, is found.3, if the search is 47, then in (6, 6) between the search,

14、 compare the (6+6) 2 item, that is, sixth items, and then (7, 6) between, because the interval left larger than the right, so the end of the search.Program code (b array from small to large order):Dim I As Integer, J As Integer, TMP As Integer, bool As Boolean, n As IntegerRem I, J search the index

15、interval, TMP is the middle index of the interval, n is the number to be searched.Bool = TrueI = 1: J = UBound (b)Do While J And bool ITMP = (I + J) 2Select Case B (TMP)Case Is nJ = TMP - 1Case Is nI = TMP + 1Case nBool = FalseEnd SelectLoopIf bool then not foundinsertGenerally refers to the inserti

16、on of ordered sequencesMethod:1, find: find more than the number of the number to be inserted (the closest)2, insert: if the number of the subscript is k, then from n to K, start moving backwards, that is, the item n moves to item n+1, item n-1 moves to item n, Item K moves to item k+1, and then put

17、s the number of inserts in item K.deleteMethod 1: delete item KStarting from item k+1 to item n, move forward in advance, that is, item k+1 moves to item K, item k+2 moves to item k+1, Move item n to item n-1.Method two: delete the value of =N1, find: find the number of =N1, find: the number in the

18、array subscript is k, then from k+1 to N, start moving forward, that is, the item k+1 moves to item K, item k+2 moves to item k+1, Move item n to item n-1.The application of two dimensional array: matrixFirst, generate matrix and display (take 4*4 matrix as an example)Dual cycleDim a (1 to 4,1 to 4)

19、 As Integer 4*4 matrix, whose values consist of row *10+ column valuesFor i=1 to 4For j=1 to 4A (I, J) =i*10+jPrint a (I, J);NextPrint “output a line and then wrap it.“NextTwo. Diagonal of matrixFor i=1 to 4For j=1 to 4If i+j=5 or i=j thenPrint a (I, J);ElsePrint SPC (4);End ifNextPrint “output a li

20、ne and then wrap it.“NextThree, matrix transpose1. Transpose only at output timeFor i=1 to 4For j=1 to 4Print a (J, I);NextPrint “output a line and then wrap it.“Next2, change the array to transpose formFor i=1 to 4For j=1 to I-1Tmp= a (J, I)A (J, I) =a (I, J)A (I, J) =tmpNextNextFour, row exchange

21、(such as the 1 line and the 3 line in the output swap) in the array swap it?For i=1 to 4If i=1 thenP=3Elseif i=3 thenP=1ElseP=iEnd ifFor j=1 to 4Print a (P, J);NextPrint “output a line and then wrap it.“NextFirst, column exchange (such as 2 column and 4 column in the output swap) in the array swap it?For i=1 to 4For j=1 to 4If j=2 thenP=4Elseif j=4 thenP=2ElseP=jEnd ifPrint a (I, P);NextPrint “output a line and then wrap it.“Next

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报