日期 |
1号 |
2号 |
3号 |
4号 |
5号 |
6号 |
7号 |
8号 |
9号 |
10号 |
最高气温℃~最低气温℃ |
22~14 |
17~12 |
10~4 |
10~2 |
8~1 |
11~8 |
17~5 |
15~4 |
19~7 |
19~7 |
若程序运行后,数组元素f(7)的值为。
Dim a(1 To 30) As String
Private Sub Form_Load( )
‘读取本月每日气温数据,存储于数组a中并在列表框List1中显示,过程略。
EndSub
PrivateSubCommand1_Click()
Dim temp(1 To 60) As Integer
Dim length As Integer, t As Integer, j As Integer
Dim ave As Single
Dim f(30) As Integer
Dim flag As Boolean
For i=1 To 30
length=Len(a(i))
j=1: t=1
Do While j<=length
If Not(Mid(a(i), j, 1)<="9" And Mid(a(i), j, 1)>="0") Then
temp(2*i-1)=Val(Mid(a(i), t, j-t))
End If
j=j+1
Loop
temp(2*i)=Val(Mid (a(i), t, j-t))
Next i
f(0)=0: low=30: flag=False
For i=1 To 30
ave=(temp(i*2-1)+temp(i*2))/2
If ave<low Then low=ave
If Not flag Then
If ave<=10 Then
Else
f(i)=0
End If
If f(i)=5 Then
Text1.Text="本月已入冬"
flag=True
End If
End If
Next i
If Then Text1.Text="本月尚未入冬"
Text1.Text=Text1.Text+""+"本月日均气温最低为:"+Str(low)
End Sub