[問(wèn)答題] 改錯(cuò)題(14分) 【題目】 本程序的功能是:找出100~999之間的十進(jìn)制數(shù)為升序數(shù),且其對(duì)應(yīng)的八進(jìn)制數(shù)也是升序數(shù)的整數(shù)。所謂升序數(shù),是指該數(shù)的
[問(wèn)答題] 改錯(cuò)題(14分) 【題目】 本程序的功能是:找出100~999之間的十進(jìn)制數(shù)為升序數(shù),且其對(duì)應(yīng)的八進(jìn)制數(shù)也是升序數(shù)的整數(shù)。所謂升序數(shù),是指該數(shù)的十位數(shù)字值大于個(gè)位數(shù)字值,百位數(shù)字值大于十位數(shù)字值。 Option Explicit Private Sub CmdFind_Click()Dim n As Integer,s8 As StringFor n=100 To 999 s8=d2Q(n) If sx(n) And sx(Val(s8)) Then List1.AddItem n & "D==>" & s8 & "Q" End IfNext n End Sub Private Function d2Q(n As Integer) As StringDim p As IntegerDo p=n Mod 8 d2Q=d2Q & CStr(P) n=n8Loop Until n=0 End Function Private Function sx(ByVal n As Integer)As BooleanDim num() As Integer,k As Integer,t As IntegerDim i As Integert=Len(CStr(n))ReDim num(t)For k=1 To t num(k)=Val(Mid(CStr(n),k,1))next kFor i=1 To UBound(num)-1 If num(i)>=num(i+1) Then Exit ForNext isx=True End Function【要求】1.新建工程,輸入上述代碼,改正程序中的錯(cuò)誤。2.改錯(cuò)時(shí),不得增加或刪除語(yǔ)句,但可適當(dāng)調(diào)整語(yǔ)句的位置。3.將窗體文件和工程文件分別命名為F1和P1,并保存到T盤根目錄下。
正確答案:Private Function d2Q(n As Integer) As String 改為ByVal n As Integer d2Q=a2Q & cstr(p) 改為cstr(p) & d2Q If num(i)>=num(i+1) Then Exit For 改為Exit Function
詞條內(nèi)容僅供參考,如果您需要解決具體問(wèn)題
(尤其在法律、醫(yī)學(xué)等領(lǐng)域),建議您咨詢相關(guān)領(lǐng)域?qū)I(yè)人士。