题库 高中信息

题干

如下程度段:
X=5
Y=-20
If  Not x>0 Then x=y-3  Else y=x+3
该程序段运行后,y的值为:
上一题 下一题 0.99难度 None 更新时间:2016-01-05 04:00:49

答案(点此获取答案解析)

同类题1

小明用 VB编写了一个连续高温天数的统计软件。小明采集了金华市 7-8 月的每日最高气温,并存放在 ACCESS数据库中。程序运行时,读取日期和最高气温并显示在列表框 List1 中,在文本框 Text1 中输入温度值,单击“统计”按钮 Command1,程序自动统计运行在该温度值及以上的最长连续天数,并显示在 Text3 中,同时在 Text2 中显示日期区间,运行界面如下图所示。

实现上述功能的 VB 代码如 下,在划线处填入合适代码。
Dim rq(1 To 100) As String ‘ 存放日期
Dim qw(1 To 100) As Integer ‘ 存放最高气温值
Dim n As Integer '总天数
Private Sub Form_Load()
' 读取数据库内容,其中日期数据存放在数组 rq 中,最高气温数据存放在 qw 中,第 i 个日期保存在 rq(i)中,对应的气温保存在 qw(i)中,并显示在列表框 List1 中,代码略
End Sub
Private Sub Command1_Click()
Dim ntempend As Integer ‘ 记录当前结束日期的下标
Dim max As Integer   ‘ 记录最大连续天数
Dim nend As Integer ‘ 记录最大连续天数下的结束日期的下标
Dim ncount As Integer ‘ 统计连续天数
Dim tjqw As Integer   ‘ 存放输入的温度
tjqw = Val(Text1.Text)
ncount = 0
max = 0
For i = 1 To n
If  ___________①___________ Then
ncount = ncount + 1
ntempend =i
Else
ncount = 0
End If
If max < ncount Then
max = ncount
___________②___________
End If
Next
If max <> 0 Then Text2.Text = ___________③___________ & "-" & rq(nend)

同类题2

日期判断:从文本框Text1输入一个8位数字表示的日期,其中第1到4位表示年(第1位确定不为零),第5到6位表示月,第7到8位表示日。单击“判断”按钮,判断该日期是否合法,将结果依次输出到列表框List1。程序界面如下图所示:
提示:年份值符合下列两种情况之一的是闰年。
1.年份是4的倍数,但不是100的倍数;
2.年份是400的倍数。

(1)观察程序代码,可知“判断”按钮的对象名为 。(单选,填字母:
A.Text1/B.List1/C.Command1/D.Judge/E.判断)
(2)为实现上述功能,请在划线处填入合适的代码。
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