题型:综合题 题类:常考题 难易度:困难
浙江省东阳中学2016-2017学年高二下学期信息技术入学考试(寒假作业检测)试卷
提示:年份值符合下列两种情况之一的是闰年。
⒈年份是4的倍数,但不是100的倍数;
⒉年份是400的倍数。
Private Sub Judge_Click()
Dim riqi As String, st As String
Dim year As Integer, month As Integer, day As Integer
Dim rn As Boolean, hefa As Boolean
riqi = Text1.Text
year = Val(Mid(riqi, 1, 4))
month = Val(Mid(riqi, 5, 2))
day = ‘第①处
st = Str(year) + "年" + Str(month) + "月" + Str(day) + "日"
rn = False ‘用于判断是否为闰年
If Then rn = True ‘第②处
If year Mod 4 = 0 And year Mod 100 <> 0 Then rn = True
hefa = True ‘用于判断是否为合法日期
If month = 0 Or month > 12 Then hefa = False
If day = 0 Then hefa = False
If (month = 1 Or month = 3 Or month = 5 Or month = 7 Or ’与下一行语句同行
month = 8 Or month = 10 Or month = 12) And day > 31 Then hefa = False
If (month = 4 Or month = 6 Or month = 9 Or month = 11) ’与下一行语句同行
And day > 30 Then hefa = False
If Then hefa = False
’第③处,判断闰年2月的天数是否合法
If month = 2 And Rn = False And day > 28 Then hefa = False
If hefa = True Then st = st + " 合法日期" Else st = st + " 非法日期"
List1.AddItem st
End Sub
a(1) |
a(2) |
a(3) |
…… |
a(n —2) |
a(n—1) |
a(n) |
3 |
25 |
38 |
…… |
55 |
31 |
12 |
依据对分查找思想,设计一个在数组a中查找数据key的程序。实现该功能的VB程序如下,但加框处代码有错,请改正。
Private Sub Command1_Click()
Const n = 6
Dim a(1 To n)As Integer,flag As Boolean
Dim i As Integer,j As Integer,m As Integer,key As Integer
'读取一组正整数,按上述规则存入数组a中,代码略。
key = VaKText1. Text)
i = 1
j = (n + 1) \ 2
flag = False
Do While And Not flag ‘①
m = (i + j) \ 2
If key = a(m) Then
flag = True
ElseIf key< a(m) Then
j = m - 1
Else
i = m + 1
End If
Loop
If Not flag And j > 0 Then
m = ‘②
If key = a(m) Then flag = True
End If
If flag Then
Text2. Text = Str(m)
Else
Text2. Text = "找不到"
End If
End Sub
①{#blank#}1{#/blank#} ②{#blank#}2{#/blank#}
试题篮