5.有如下VB程序段: For i=2 to 5 For j=i to 5 If j mod i=0 then a(j)=a(j)+1 Next j Next i For i=1 to 5 If a (i)<>1 then s=str(i)+s Next i 若數組a 的初始值都為0,則運行該程序段后,s的值為( )
(填行列或格子編號均可)。 (2)實現上述功能的部分VB程序如下,請在橫線處填入合適的代碼。 Const n=10 Dim a(100)As String,steps(3)As Integer,pos(2)As Integer Dim towards(2)As Integer,cur As Integer,nex As Integer,K As Integer Private Sub Form_Load ______ '生成矩陣存儲在數組a中并輸出,代碼略 End Sub Private Sub Command1_Click_____ steps(0)=-n:steps(1)=1:steps(2)=n:steps(3)=-1 pos(1)=1:towards(1)=1:pos(2)=n*n:towards(2)=3 i=1:K=Val(Text1.Text) Do While i<=K cur=(i-1)Mod 2+1 nex=GetNext(pos(cur),towards(cur)) Do While Check(nex) pos(cur)=nex nex=GetNext(pos(cur),towards(cur)) Loop nex=GetNext(pos(cur),towards(cur)) Do While Not Check(nex) towards(cur)=______ nex=GetNext(pos(cur),towards(cur)) Loop i=i+1 Loop '輸出矩陣,代碼略 End Sub Function Check(x As Integer) As Boolean Check=x<>0 And a(x)<>“#“And _____ End Function Function GetNext(x,t) As Integer GetNext=x+steps(t) If x>=1 And x<=n And t=0 Then GetNext=0 If x>(n-1)*n And x<=n*n And t=2 Then GetNext=0 If _____ Then GetNext=0 If x Mod n=0 And t=1 Then GetNext=0 End Function