套题一上机
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
套题一上机
六、程序设计题(每小题10分,共20分)
1.
Private Sub Command1_Click()
Dim a(0 To 9) As Integer
s = Text1.Text
For i = 1 To Len(s)
c = Val(Mid(s, i, 1))
a(c) = a(c) + 1
Next i
For j = 0 To 9
Label1.Caption = Label1.Caption & j & "出现的次数= " & a(j) & Chr(13) & Chr(10) Next j
End Sub
2.
Private Sub Form_Click()
Dim house As Single, m As Single, w As Single, y As Integer
house = 70 * 3.0479
m = 0
w = 0.5
y = 0
Do While m < house
m = m + w * 12
w = w * 1.05
house = house * 1.03
y = y + 1
Loop
Print y
End Sub
8.1.2实战套题一上机试卷1
1.
Private Sub Form_Click()
Randomize
Cls
Dim x(1 To 5)
For k = 1 To 5 ' 产生随机数
x(k) = Int(Rnd * 9000 + 1000)
Next k
Scale (-0.5, 10100)-(6, -2000) ' 自定义坐标系
Line (0, 10000)-(0, -0) ' 画纵轴
Line (0, 0)-(5.5, 0) ' 画横轴
For k = 1 To 5 ' 画直方图
Line (k - 0.5, x(k))-(k, 0), , BF
Next k
CurrentY = -200
For k = 1 To 5 ' 标横轴的数字
CurrentX = (k - 0.5)
Print x(k);
Next k
End Sub
2.
Private Sub Command1_Click()
Taxi = Val(Text1.Text)
If Taxi <= 3 Then
Fee = 7
ElseIf Taxi <= 15 Then
Fee = 7 + 1.2 * (Taxi - 3)
Else
Fee = 7 + 1.2 * 12 + 1.8 * (Taxi - 15)
End If
Label2.Caption = "应付出租车费:" & Fee & "元"
End Sub
3.
Private Sub Form_Click()
Dim a As Variant, b As Variant
a = Array(85, 77, 92, 66, 44)
b = Array("黄玉梅", "朱明霞", "孙家宝", "赵天明", "杨百万")
Max = a(0)
student = b(0)
For i = 1 To 4
If a(i) > Max Then
Max = a(i)
student = b(i)
End If
Next i
Print "成绩最好的学生是:"; student; " 考试成绩为:"; Max; "分" End Sub
8.1.3实战套题一上机试卷2
1.
Dim x1 As Single, y1 As Single, x2 As Single, y2 As Single
Private Sub Form_Load()
ScaleMode = 6
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Cls
x1 = X
y1 = Y
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) x2 = X
y2 = Y
Line (x1, y1)-(x2, y2), , B
s = Abs(x1 - x2) * Abs(y1 - y2)
Print "矩形的宽度* 高度= " & Round(x2 - x1, 2) & " * " & Round(y2 - y1, 2) & "(毫米)"
Print "矩形的面积为= " & Round(s, 2) & "(平方毫米)"
End Sub
2.
Private Sub Command1_Click()
chip = Val(Text1.Text)
price = 8
If chip <= 100 Then
Fee = chip * price
ElseIf chip > 100 And chip <= 300 Then
Fee = 100 * price + (chip - 100) * price * 0.9
Else
Fee = 100 * price + 200 * price * 0.9 + (chip - 300) * price * 0.8
End If
Label2.Caption = "采购" & chip & "片芯片总共应付" & Fee & "元"
End Sub
3.
Private Sub Form_Click()
Dim score As Variant
score = Array(93.88, 91.77, 92.66, 94.55, 90.99, 96.11, 97.22)
Max = score(0)
Min = score(0)
Sum = score(0)
For i = 1 To 6
If score(i) > Max Then Max = score(i)
If score(i) < Min Then Min = score(i)
Sum = Sum + score(i)
Next i