編程任務:輸入正整數n,統計n的約數個數.其基本算法描述如圖所示,請根據圖示算法將代碼補充完整: Dim n As Integer,i As Integer Dim count As Integer,k As Integer n=Val(Text1.Text) k=Sqr(n) count=1 For i=2 To k Step 1 If
n mod i=0
n mod i=0
Then count=
count+1
count+1
End If Next i If n>1 Then count=count+1 End If Label2.Caption=“約數個數是:
3.【加試題】小丫覺得回文字符串太優美了(回文字符串是指順讀和倒讀都一樣的字符串,如“123321”),為此編寫了VB 程序。程序運行時,單擊按鈕Command1 后,根據文本框Text1 中輸入的內容判斷并輸出是不是回文串。實現上述功能的VB 代碼如下。 Private Sub Command1_Click( ) Dim s As String,f As Boolean,L As Integer s=Text1.Text j=Len(s) i=1 Do while ① i=i+1 j=j-1 Loop If ②Then Print“是回文串“Else Print“不是回文串“ End Sub 在畫線處填入合適代碼,使程序能正常運行。 ①