题库 高中信息

题干

某学校高一年级共有500名学生,10个班,现需要根据某次考试的技术成绩从高到低进行考试号编排,考试号从100开始,如出现成绩一样的情况,则考试号按学生学号从大到小编排,如图所示。为此,小王编写了一个VB程序,程序功能如下:单击“读取数据”按钮 Command1,程序从数据库中读取学生的学号、成绩分别存储在数组xh、cj中,并在列表框List1输出;单击“编排”按钮Command2,程序进行处理,输出结果在列表框List2中。程序运行界面如图所示。
实现以上功能的VB程序如下,请回答下列问题:
(1)如原始数据里漏输了一个学生,已知该学生的学号为“20170240”,成绩为“99”,则增加该学生数据后,运行程序时,该学生的考试号为________。
(2)请在画线处填入合适的代码。
Const n=500
Dim xh(1 To n) As Integer    '存放学生学号
Dim cj(1 To n) As Integer    '存放学生成绩
Dim I,d,k,t,y As Integer
Private Sub Command1 Click()
'本过程从数据库中读取学生数据,存储在相应的变量中,并在List1中显示
'代码略
End Sub
Private Sub Command2_Click()
For i=1 To n-1

For j=n To i+1 Step-1

If c(j)>cj(j-1) Then
t=ci(j):cj(j)=cj(j-1):cj(j-1)=t
t=xh(j):xh(j)=xh(j-1):xh(j-1)=t
End If

 

Next j

Next i
k=1
For i=2 To n

If______Then

k=k+1
y=0

Else

y=1

End If

If (y=l And k> 1) Or (i=n And k> 1) Then

For d=i-k To i-2
For______To(i-k+1) Step-1
If xh(j)>xh(j-1) Then
t=xh(j):xh(i)=xh(j-1):xh(j-1)=t
End If
Next j
Next d
k=1

End If

Next i
List2.Clear
List2.AddItem " "+"学号"+"  "+"技术成绩"+"  "+"考试号"
For i=1 To n
List2.AddItem Str(xh(i))+"  "+Str(cj(i))+"  "+_____
Next i
End Sub
上一题 下一题 0.99难度 None 更新时间:2020-03-30 11:10:18

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

同类题4

小王设计制作了一个VB程序用于获取英文单词,然后背诵这些英文单词。为了使背诵英文单词更有效率,小王决定要显示的英文单词要由相同的英文字幕组成。
程序执行过程如下:程序运行后,先从数据库中获取单词,然后单击“分析单词”按钮,查找出由相回字母组成的英多单词保留下来显示,例如:获取的英文单词有:tea,pea,eta,eat,help,three,there。通过分析得知tea,eta和eat是由相同字母组成的英文单词,three和there是由相同字母组成的英文单词,则这五个英文单词保留下来,显示在label1中。如图所示:

VB部分程序如下,请将程序补充完整:
Dim wordcharsort (1 To 3000)As String'存储每个英文单词字母排序后的内容
Dim words (1 To 3000) As string'存储由相同字母组成的英文单词
Dim wordscount As Integer
Dim Getwords (1 To 3000) As String
Private Sub Form_Load()
'从数据库中获取3000个英文单词存储到数组 Getwords中,代码略
End Sub
Private Sub Command1_ Click()

Dim key As Integer

For i=1 To 3000

Wordcharsort(i)=rank(Getwords(i))

Next i

For i=1 To 3000-1

k=i
For j=i+1 To 3000
If wordcharsort(j)<wordcharsort(k) Then k=j
Next j
If i<>k Then
t1= wordcharsort(i):wordcharsort(i)= wordcharsort(k):wordcharsort(k)=tl
___________
End if
Next i
For key=1 To 3000
wordscount= search( wordcharsort(key),key, wordscount)
Next key
For i=1 To wordscount
Label1. Caption= Labell. Caption+" "+words(i)
Next i
End sub
'查找相同字母组成的英文单词,存储在 words数组中
Function search(a As String, b As Integer, c As Integer)As Integer

For i=1 To 3000

flag=False

If a=wordcharsort(i) And______ Then
For j=1 To c
If words(j)=Getwords(b) Then flag=True
Next j
If flag=False Then
Words(c)=Getwords(b)
__________
End if
End If
Next i
search=c
End function
'对英文单词中的字母进行排序
Function rank(s As String)As String

Dim c(l To 45) As String

wordscount=1

For xk=1 To 45

c(xk)=" "

Next xk

For j=1 To Len(s)

c(j)= _______

Next j

For k=1 To Len (s)-1

For kk=Len(s) To k+1 Step-1

If Asc(c(kk))<Asc(c(kk-1))Then
tmp=c(kk):c(kk)=c(kk-1):c(kk-1)=tmp
End if
Next kk
Next k
For j=1 To Len(s)
rank -rank & c(i)
Next j
End function