16.【加試題】某地2017.1-2017.2月的日期及日最高氣溫?cái)?shù)據(jù)保存在數(shù)據(jù)庫(kù)中.現(xiàn)要求根據(jù)日最高氣溫,找出這兩個(gè)月中連續(xù)降溫的次數(shù)、連續(xù)最長(zhǎng)降溫天數(shù)及其日期.小劉為此編寫(xiě)了VB程序,程序運(yùn)行時(shí),單擊按鈕Command1后,在標(biāo)簽Label1和Label2上輸出運(yùn)行結(jié)果.實(shí)現(xiàn)上述功能的VB代碼如下,但加框處代碼有錯(cuò),請(qǐng)改正. Dim a(1 To 59)As String'依次存儲(chǔ)2017.1-2017.2月的日期數(shù)據(jù) Dim b(1 To 59)As Integer'依次存儲(chǔ)2017.1-2017.2月的日最高氣溫?cái)?shù)據(jù) Private Sub Form_Load( ?。?br />'本過(guò)程從數(shù)據(jù)庫(kù)中按2017.1-2017.2的日期次序,讀取日期和日最高氣溫?cái)?shù)據(jù),分別存儲(chǔ)在數(shù)組a和數(shù)組b中 '代碼略 End Sub Private Sub Command1_Click( ?。?br /> Dim d As Integer,n As Integer Dim dmax As Integer,m As Integer n=0:d=1:dmax=1 For i=2 To 59 If Then'① d=1+1 Else d=1 EndIf If d=2 Then n=n+1 If d>dmax Then dmax=d m=i EndIf Next i Label1.Caption=“連續(xù)降溫次數(shù)“& Str(n) Label2.Caption=“連續(xù)最長(zhǎng)降溫日期為:“& &“-“& Str(a(m)) &“持續(xù)天數(shù)為:“& Str(dmax)'② End Sub (1)①處應(yīng)改為
實(shí)現(xiàn)上述功能的VB程序如下: (1)請(qǐng)?jiān)诋?huà)線(xiàn)處填入合適代碼. Dim a(1 To 30)As Integer,b(1 To 30)As Integer,ans(1 To 60)As Integer Dim La As Integer,Lb As Integer,length As Integer Private Sub Command1_Click( ) Dim i As Integer,j As Integer,t As Integer,temp As String '將兩個(gè)乘數(shù)(正整數(shù))各數(shù)位上的數(shù)字按照上述算法依次存入數(shù)組a和b,每個(gè)正整數(shù)位數(shù)分別保存到變量La和Lb;將保存結(jié)果的數(shù)組ans(i)值初始化為零(該部分程序代碼略) For i=1 To Lb'按低位到高位的順序進(jìn)行列豎式的逐位乘法 For j=1 To La ans(i+j-1)=
+b(i)*a(j) Next j Next i For i=1 To La+Lb'對(duì)計(jì)算結(jié)果進(jìn)行進(jìn)位處理 ans(i+1)=ans(i+1)+ans(i)\10 ans(i)=
Next i Length=La+Lb Do While ans(lenth)=0 length=length-1 Loop For i=
To 1 Step-1 Label4.Caption=Label4.Caption & Str(ans(i)) Next i End Sub (2)根據(jù)本題算法,若輸入的兩個(gè)整數(shù)分別為5125和18,則在輸出乘法計(jì)算結(jié)果時(shí),變量length的值為