【答案解析】[操作步骤]
步骤1:打开本题工程文件。
步骤2:分析并编写程序代码。
程序提供代码
Option Base 1
Dim a(12, 10)As Long, s(12)As Long
Private Sub Command1_Click()
Open App. Path & "/in5.dat" For Input As #1
For i=1 To 12
For j=1 To 10
Input #1, a(i, j)
Next j
Next i
Close #1
End Sub
Private Sub Command2_Click()
考生编写
End Sub
Private Sub Command3_Click()
以下程序段在Text1文本框内显示每组数的组号及平均值
Text1. Text=" "
For i=1 To 12
If i<10 Then
Text1. Text=Text1. Text+" "+str(i)+" "+str(s(i))+Chr$(13)+Chr$(10)
Else
Text1. Text=Text1. Text+str(i)+" "+str(s(i))+Chr $ (13)+Chr $ (10)
End If
Next i
End Sub
Private Sub Command4_Click()
Open App. Path & "/out5.dat" For Oulput As #1
For i=1 To 12
Print #1, s(i)
Next i
Close #1
End Sub
程序结束
Private Sub Command2_Click()
考生编写
Dim q As Long
For m=1 To 12
q=0
For n=1 To 10
q=q+a(m, n)
Next n
s(m)=Int(q/10)
Next m
End Sub
步骤3:调试并运行程序,关闭程序后按题目要求存盘。
答案考生文件夹
[解析] 将考生文件夹下文件in5.dat中的12组整数读到数组a中;在Command2 Click事件过程中,通过循环嵌套对每组数据求平均值,并将其值运用Int函数截尾取整后存入s数组中;运用If语句进行判断,使1-9的组号后添加一个空格,保持数列的整齐。