計算機二級vb考試試題(附答案)
Next j
If ___(20)___ Then
k=k+1
Text1.Text=Text1.Text & i & " "
If k Mod 5=0 Then Text1.Text=Text1.Text & vbCrlf
End If
Next i
EndSub
Public Function judge(ByVal x As Integer)As Boolean
If ___(21)___ Then
judge=True
Else
judge=False
End If
End Function
8.本程序的功能是:找出所有滿足各位數字之和正好是其所有質因子之和的三位數。例如378,其各
位數字之和為18,而其質因子2,3,3,3,7之和也是18,所以378是滿足條件的數。
Option Explicit
Private Sub CmdFind_Click()
Dim i As Integer,p As String,st As String,st1 As String
For i=100 To 999
___(22)___
If csum(i)=zyz(i,st) Then
p=CStr(i)
st1=Left(p,1) & "+" & Mid(p,2,1) & "+" & Right(p,1)
List1.AddItem i & ": " & st1 & "=" & Left(st,Len(st)-1)
End If
Next i
If List1.ListCount=0 Then
List1.AddItem "無滿足要求的數!"
End If
End Sub
Private Function csum(m As Integer)As Integer '求各位數字之和
Dim i As Integer,p As String
p=CStr(m)
For i=1 To Len(p)
___(23)___
Next i
End Function
Private Function zyz(ByVal m As Integer,st As String)As Integer '求所有質因子之和
Dim i As Integer
i=2
Do
If m Mod i=0 Then
zyz=zyz+i
st=st & i & "+"
m=m\i
EIse
___(24)___
End If
Loop Until ___(25)___
End Function
9.本程序的功能是,按"年/月/日"格式輸入日期,計算出該日期是該年份中的第幾天,過程leap_year
用于判斷該年份是否為閏年(能被4整除且不能被100整除或能被400整除的年份為閏年)。
Private Sub Commandl_Click()
Dim st As String,rq(3)As Integeb k As Integer,d As Integer
Dim p As String*1,q As String,i As Integer,dt As Integer
st=Trim(Text1)
i=1
Do
p=Mid(st,i,1)
If p<>"/" Then
q=q & p
Else
k=k+1
rq(k)=Val(q)
___(26)___
End If
i=___(27)___
Loop Until i>Len(st)
k=k+1
rq(k)=q
For i=___(28)___ To 1 Step -1
Select Case i
Case 1,3,5,7,8,10
dt=31
Case 2
If leap_year(rq(1))Then
dt=29
Else
dt=28
End If
Case Else
dt=30
End Select
d= ___(29)___
Next i
Text2=d+rq(3)
End Sub
Private Function leap_year(n As Integer)As Boolean
If ___(30)___ Then
leap_year=True
ElseIf n Mod 400=0 Then
leap_year=True
End If
End Function
計算機等級二級VB考試參考答案
(1)B (2)B (3)B (4)A (5)D (6)B(7)A (8)B (9)D (10)C
(11)C(12)D (13)A (14)D (15)B(16)D (17)C (18)D (19)C (20)C
(21)A (22)B (23)B (24)C (25)B (26)B (27)B (28)C (29)D (30)A
二、填空題
(1)6 11 (2)10 21 (3)13 34(4)6 (5)8 (6)3 (7)2 (8)8 (9)32
(10)2 (11)16 (12)207(13)-27 (14)22 (15)-11(16)n=n+1 (17)abs(t)<=1e-7
(18)p*(2*i-1)/(2*i) (19)p=j*j (20)j=int(sqr(i))+1 或j>int(sqr(i))(21)int(sqr(x))=sqr(x)
(22)st="" (23)csum=csum+val(mid(p,i,1))(24)i=i+1 (25)m=1(26)q="" (27)i+1 (28)rq(2)-1
(29)d+dt (30)n mod 4=0 and n mod 100<>0
【計算機二級vb考試試題(附答案)】相關文章: