题型:综合题 题类:常考题 难易度:普通
【bj】高中信息技术综合库——解析算法2
Dim i As Integer, m As Integer, flag as Boolean
m =
flag=
For i = 2 To int(sqr(m))
If Then
flag=false
Exit For
End if
Next i
If flag=true Then
Text2.Text = str(m) +"是素数"
Else
Text2.Text = str(m) +"不是素数"
End if
分数 |
0~59 |
60~69 |
70~79 |
80~89 |
90~99 |
等级 |
E级 |
D级 |
C级 |
B级 |
A级 |
现要求根据上表统计出各等级学生人数占总人数的比例。小李编写了一个VB程序帮助老师实现该功能:程序运行时,将每位学生的得分(两位整数)存储到数组a中,并在列表框List1
中显示。单击“统计”按钮后,在列表框List2中显示从A级至E级,各等级的人数占总人数的百分比例(四舍五入保留整数)。程序运行界面如图所示:
请阅读代码,并回答以下问题:
Dim n As Integer
Dim a(1 To 50) As Integer
Private Sub Form_Load( )
Dim adocn As New ADODB. Connection
Dim adors As New ADODB. Recordset
Dim str1 As String
adocn.ConnectionString = "Provider = Microsof.ACE.OLEDB.12.0;Data source=" +App. Path +”\school. accdb”
adocn. Open
str1 =“select * from students”
ardors.Open str1, adocn
'将每个学生的得分读入数组a中,并在列表框list1中显示,统计学生总人数n
'代码略
End Sub
Private Sub Comd1_C1ick( )
Dim cou As Integer,k as Integer
Dim b(0 To 4) As Integer
Const dj = “A级B级C级D级E级”
For i=1 Ton
k=a(i)\10-5
If k<0 Then ①
b(k)= b(k) + 1
Next i
For i=0 To 4
cou = '⑶改错
List2. AddItem ② + Str(cou) +“%”
Next i
End Sub
a=[30,10,20,11,12,50] d=[0]*6 ; max=0 ; n=len(a) for i in range(1,n): for j in range(i): if a[j]<a[i]: d[i]+=1 if d[i]>max: max=d[i] |
执行程序后,变量max的值是( )
试题篮