Const n=20 Dim a(l To n)As Integer Private Sub Form_Load( ?。?br />“隨機(jī)生成n個(gè)數(shù),存儲(chǔ)于數(shù)組a中,并輸出在Listl中。 “代碼略。 End sub Private Sub Command1_Click( ?。?br /> Dim count As Integer Dim high As Integer Dim peak As Integer Dim i As Integerj As Integer count=0 if a(1)>a(2)then count=1 high=-1 i=1 Do While i<n-1 j=i+1 If a(j)>a(j-1)Then Do While a(j)>a(j-1) j=j+1 Lop count=count+1 ① List2.AddItem“第“+Str(count)+“個(gè)峰值:“+Str(peak) If peak>high Then high=peak ② Else i=i+1 End If Loop List2.AddItem“共有:““+Str(coun+)+“個(gè)峰值:“+Str(peak) List2.AddItem“最高點(diǎn)是:“+Str(high) End Sub
(1)實(shí)現(xiàn)上述功能的VB程序如下請(qǐng)完善橫線處的代碼。 Dim red(1 To 600)As Integer“用于存儲(chǔ)100*6紅色球信息 Dim blue(1 To 100)As Integer“用于存儲(chǔ)100*1藍(lán)色球信息 Private Sub Form_Load( ?。?br />“本過程用于從數(shù)據(jù)庫(kù) data.accdb中讀取最近100期雙色球開獎(jiǎng)信息 “將100*6個(gè)紅色球開獎(jiǎng)信息依次存儲(chǔ)在數(shù)組red( ?。┲?br />“將100*1個(gè)藍(lán)色球開獎(jiǎng)信息依次存儲(chǔ)在數(shù)組blue( )中 “將最近100期開獎(jiǎng)信息格式化后顯示在列表框Listl中 “本過程代碼略 End Sub Private Sub Commandl_Click( ?。?br />Dim min As Integer Dim s As string Dim f(1 To 33)As Integer “------以下開始處理藍(lán)色球部分--------- For b=1 To 100 f(blue(b))=f(blue(b))+1 Next b min=100 For i=1 To 16 If f(i<min Then min=f(i) Next i For i 1 To 16 If f (i)=min Then s=①
f(i)=0 Next i List2.AddItem“藍(lán)色球重點(diǎn)買入:“+s “---------以下開始處理紅色球部分-------- For r=1 To 600 ②
Next r ③
For i=1 To 6“查找概率最低的6個(gè)紅球數(shù)字 k=1 For j=2 To 33 if f(j)<f(k) Then k=j Next j s=s+Str(k) f(k)=100 Next i list2.AddItem“紅色球重點(diǎn)買入:“+s“第(2)題紅球購(gòu)買建議 End Sub