實(shí)驗(yàn)E數(shù)組和自定義類型(精)_第1頁
實(shí)驗(yàn)E數(shù)組和自定義類型(精)_第2頁
實(shí)驗(yàn)E數(shù)組和自定義類型(精)_第3頁
實(shí)驗(yàn)E數(shù)組和自定義類型(精)_第4頁
實(shí)驗(yàn)E數(shù)組和自定義類型(精)_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、實(shí)驗(yàn)E :數(shù)組和自定義類型 目的掌握數(shù)組的概念;體會(huì)數(shù)組在處理有序數(shù)據(jù)方面的優(yōu)越性;掌握數(shù)組的常用解題算法。 內(nèi)容教材中實(shí)驗(yàn):1、2、3、4、5、61、Private Sub Form_Click(Dim a(1 To 10 As In teger, i%, maxa%, min a%, avera!For i = 1 To 10a(i = Int(Rnd * 100Next imina = a(1maxa = a(1avera = a(1For i = 2 To 10If a(i maxa The n maxa = a(iIf a(i mi na The n mi na = a(iavera

2、 = avera + a(iNext iFor i = 1 To 10Print a(i;Next iPrintPrint max=; maxa, min=; mina, aver二;avera / 10End Sub2、Private Sub Form_Click(Dim aa = Array(56, 78, 98, 88, 76, 78For i = 0 To 5Print String(a(i 5, ; a(iPrintNext iEnd Sub3、統(tǒng)計(jì)各分?jǐn)?shù)段的個(gè)數(shù)Dim a(1 To 20 As In tegerPrivate Sub Comma nd1_Click(Ran domi

3、zeFor i = 1 To 20a(i = Int(Rnd * 101j = j + 1Picturel.Print Tab(6 * j - 5; a(i; If j Mod 4 = 0 Then Picture1.Print: j = 0 Next iEnd SubPrivate Sub Comma nd2_Click( Dim s(5 To 9 As In tegerFor i = 1 To 20j = a(i 10If j 6 Thens(5 = s(5 + 1ElseIf j 9 Thens(j = s(j + 1Elses(9 = s(9 + 1End IfNext iPictur

4、e2.Print s(; i;的人數(shù)有;s(i Next iEnd Sub4、Private Sub Form_Click(Dim a(1 To 10 As In tegerRan domizeFor i = 1 To 10a(i = Int(Rnd * 90 + 10Print a(i;Next iPrintFor i = 1 To 9k = iFor j = i + 1 To 10If a(k a(j The n k = jNext jt = a(i: a(i = a(k: a(k = tNext iPrint a(i;Next iEnd Sub5、Dim a%(3, 3, b%(3, 3

5、Private Sub Form_Load(Ran domizeFor i = 0 To 3Forj = 0 To 3a(i, j = In t(R nd * 36 + 35b(i, j = Int(Rnd * 41 + 100Next jNext iEnd SubPrivate Sub Comma nd1_Click(Picturel.CIsFor i = 0 To 3Forj = 0 To iPicturel.Pri nt a(i, j;Next jPicturel.Pri ntNext iEnd SubPrivate Sub Comma nd2_Click(Picture2.ClsFor

6、 i = 0 To 3For j = i To 3Picture2.Pri nt Tab(j * 6; b(i, j;Next jPicture2.Pri ntNext iEnd SubPrivate Sub Comma nd3_Click(Picture3.Clssa = 0For i = 0 To 3sa = sa + a(i, iNext isb = 0For i = 0 To 3sb = sb + b(i, 3 - iNext iPicture3.Print A數(shù)組主對(duì)角線元素和為:;sa Picture3.Print B數(shù)組副對(duì)角線元素和為:;sb End Sub6、Private

7、Sub Picture1_Click(Dim s(20, 20 As Integer n = Val(Text1.Text Picture1.ClsFor i = 1 To ns(i, 1 = 1: s(i, i = 1Next iFor i = 3 To nForj = 2 To i- 1s(i, j = s(i - 1, j - 1 + s(i - 1, jFor i = 1 To nForj = 1 To iPicturel.Pri nt Tab(1 + 4 * j; s(i, j; Next jPicturel.Pri ntNext iEnd Sub楊輝三角形的第二種方法Private Sub Picture1_Click(Dim s(20, 20 As In tegern = Val(Text1.TextPicture1.ClsFor i = 1 To ns(i, 1 = 1: s(i, i = 1Next iFor i = 3 To nForj = 2 To i- 1s(i, j = s(i - 1, j - 1 +

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論