问题
填空题
以下程序的功能是,从键盘上输入若干学生的成绩,统计并输出最高分数和最低分数,当输入负数时结束输入,请填空。
Private Sub Command1_C1iek()
Dim x As Single
Dim amax As Single,amln As Single
x=InputBox("请输入分数")
amax=x
amin=x
Do While 【8】
If x>amax Then
amax=x
End If
If 【9】 Then
amin=x
End If
x=InputBox("请输入分数")
Loop
Print amax,amin
End Sub
答案
参考答案:[8] x>=0或Not x<0
[9] x<amin或Not x>=amin
解析: 本题主要是对求最值算法的考查。题中要求当输入负数时结束输入,可知控制程序的条件应是输人数x必须大于等于0。用语句表示应为x>=0或Not x<0。程序中用变量amin存放最低分,又因为语句amin= x,则可推断出x值比初始化时的最低分要小的条件。故条件表达式应写成x<amin或 Not x>=amin。