为了考试准备的!!!记录学习过程和方便复习!!!
为了考试准备的!!!记录学习过程和方便复习!!!
为了考试准备的!!!记录学习过程和方便复习!!!
试题0301
Private Sub Command1_Click()
Dim m As Integer, n As Integer
Dim s As Long
Dim i As Integer
m = Val(Text1.Text)
n = Val(Text2.Text)
s = 1
For i = m To n
If i Mod 2 = 0 Then s = s * i
Next i
Print s
End Sub
试题0302
Private Sub Command1_Click()
Dim m As Integer, n As Integer
Dim s As Integer
Dim i As Integer
m = Val(Text1.Text)
n = Val(Text2.Text)
For i = m To n
If i Mod 3 = 0 Then s = s + i ^ 2
Next i
Print s
End Sub
试题0303
Private Sub Command1_Click()
Dim m As Integer, n As Integer
Dim s As Integer, count As Integer, aver As Integer
Dim i As Integer
m = Val(Text1.Text)
n = Val(Text2.Text)
For i = m To n
If i Mod 2 = 0 Then
s = s + i
count = count + 1
End If
Next i
aver = s / count
Print CStr(aver)
End Sub
试题0304
Private Sub Command1_Click()
Dim m As Integer, n As Integer
Dim count As Integer
Dim i As Integer
m = Val(Text1.Text)
n = Val(Text2.Text)
For i = m To n
If i Mod 7 = 0 Then count = count + 1
Next i
Print "能被7整除的个数有:" & CStr(count) & "个"
End Sub
试题0305
Private Sub Command1_Click()
Dim deposit As Single, years As Integer
deposit = Val(Text1.Text)
years = Val(Text2.Text)
For i = 1 To years
deposit = deposit + deposit * 0.04
Next i
Print "5年后的本息为:" & CStr(deposit) & "元"
End Sub
试题0306
Private Sub Command1_Click()
Dim n As Integer
Dim i As Integer
n = Val(Text1.Text)
For i = 2 To Sqr(n)
If n Mod i = 0 Then Exit For
Next i
If i > Sqr(n) Then
Label2.Caption = CStr(n) & "是质数!"
Else
Label2.Caption = CStr(n) & "不是质数!"
End If
End Sub
试题0307
Private Sub Command1_Click()
Dim a As Integer, b As Integer
Dim count As Integer
Dim i As Integer
Print "所有2位的降序数有:"
For i = 10 To 99
a = i \ 10
b = i Mod 10
If a >= b Then
Print Str(i);
count = count + 1
If count Mod 10 = 0 Then Print
End If
Next i
End Sub
试题0308
Private Sub Command1_Click()
Dim n As Integer, s As Long
Dim i As Integer
n = Val(Text1.Text)
s = 1
For i = 1 To n
s = s * i
Next i
Label2.Caption = CStr(n) & "的阶乘为:" & CStr(s)
End Sub
试题0309
Private Sub Command1_Click()
Dim i As Integer
Print "1000以内的守形数有:"
For i = 1 To 1000
n = Val(Right(CStr(i ^ 2), Len(CStr(i))))
If i = n Then Print CStr(i)
Next i
End Sub
试题0310
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer
Dim i As Integer
Print "水仙花数有:"
For i = 100 To 999
a = i \ 100
b = i \ 10 Mod 10
c = i Mod 10
If a ^ 3 + b ^ 3 + c ^ 3 = i Then Print CStr(i)
Next i
End Sub
试题0311
Private Sub Command1_Click()
Dim i As Integer, s As Integer
For i = 0 To 200
If i Mod 3 = 0 Or i Mod 7 = 0 Then s = s + i
Next i
Text1.Text = CStr(s)
End Sub
试题0312
Private Sub Command1_Click()
Dim a(5) As Integer, max As Integer
Dim i As Integer
For i = 0 To 4
a(i) = Rnd * 10
s = s & a(i) & Chr(9)
If max < a(i) Then max = a(i)
Next i
Text1.Text = s & "最大值:" & CStr(max)
End Sub
试题0313
Private Sub Command1_Click()
Dim deposit As Single, years As Single
Dim money As Integer
deposit = Val(Text1.Text)
years = Val(Text2.Text)
Select Case years
Case Is > 5
money = deposit * 0.07
Case Is > 3
money = deposit * 0.05
Case Else
money = deposit * 0.03
End Select
MsgBox "利息:" & CStr(money) & "Ôª"
End Sub
试题0314
Private Sub Command1_Click()
Dim n As Integer, s As Integer
Dim i As Integer
For i = 1 To 10
n = Rnd * 200 + 100
Print n;
If n Mod 2 = 0 Then s = s + n
Next i
Print
Print "偶数和:" & CStr(s)
End Sub
试题0315
Private Sub Command1_Click()
Dim n As Integer, s As Integer
Dim i As Integer
For i = 1 To 10
n = Rnd * 40 + 10
Print n;
If n Mod 2 <> 0 Then s = s + n ^ 2
Next i
Print
Print "奇数平方和:" & CStr(s)
End Sub
试题0316
Private Sub Command1_Click()
Dim n As Integer, count As Integer
Dim i As Integer
For i = 1 To 10
n = Rnd * 300 + 300
Print n;
If n Mod 13 = 0 Then count = count + 1
Next i
Print
Print "能被13整除的个数:" & CStr(count)
End Sub
试题0317
Private Sub Command1_Click()
Dim n As Integer, count As Integer
Dim i As Integer
For i = 1 To 10
n = Rnd * 88 + 11
Print n;
If n Mod 10 = 3 Then count = count + 1
Next i
Print
Print "个位数是3的个数:" & CStr(count)
End Sub
试题0318
Private Sub Command1_Click()
Dim n As Integer, s As Integer
Dim i As Integer
For i = 1 To 10
n = Rnd * 44 + 50
Print n;
If n Mod 3 = 0 Then s = s + n
Next i
Print
Print "能被3整除的数之和:" & CStr(s)
End Sub
试题0319
Private Sub Command1_Click()
Dim n As Integer, count As Integer
Dim i As Integer
For i = 1 To 10
n = Rnd * 10 + 5
Print n;
If n ^ 2 > 50 Then count = count + 1
Next i
Print
Print "平方和大于50的个数:" & CStr(count)
End Sub
试题0320
Private Sub Command1_Click()
Dim n As Integer, count As Integer
Dim i As Integer
For i = 1 To 10
n = Rnd * 10 + 10
Print n;
If n ^ 3 < 5000 Then count = count + 1
Next i
Print
Print "立方数小于5000的个数:" & CStr(count)
End Sub
试题0321
Private Sub Command1_Click()
Dim n As Integer
Dim count_0 As Integer, count_1 As Integer
Dim i As Integer
For i = 1 To 10
n = Rnd * 900 + 100
Print n;
If n Mod 2 = 0 Then
count_0 = count_0 + 1
Else
count_1 = count_1 + 1
End If
Next i
Print
Print "偶数比奇数多:" & CStr(count_0 - count_1) & "个"
End Sub
试题0322
Private Sub Command1_Click()
Dim n As Integer, min As Integer
Dim i As Integer
For i = 1 To 10
n = Rnd * 40 + 30
Print n;
If i = 1 Or min > n Then min = n
Next i
Print
Print "最小值:" & CStr(min)
End Sub
试题0323
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Dim i As Integer
For i = 1000 To 9999
a = i \ 1000
b = i \ 100 Mod 10
c = i \ 10 Mod 10
d = i Mod 10
If a ^ 4 + b ^ 4 + c ^ 4 + d ^ 4 = i Then Print i
Next i
End Sub
试题0324
Private Sub Command1_Click()
Dim n As Integer
Dim i As Integer
For i = 1000 To 9099
If i \ 100 Mod 10 = 0 Then
n = (i \ 1000) * 100 + i Mod 100
If n * 9 = i Then Print i
End If
If i Mod 100 = 99 Then i = i + 900
Next i
End Sub
试题0325
Private Sub Command1_Click()
Dim n As Long
Dim i As Long
For i = 1000 To 9999
n = i * 4
If i = Val(StrReverse(CStr(n))) Then Print i
Next i
End Sub
试题0326
Private Sub Command1_Click()
Dim m As Integer, n As Integer
Dim t As Integer
Dim i As Integer
m = Val(Text1.Text)
n = Val(Text2.Text)
If m < n Then
t = m
m = n
n = t
End If
While n <> 0
t = m Mod n
m = n
n = t
Wend
Label3.Caption = CStr(m)
End Sub
试题0327
Private Sub Command1_Click()
Dim n As Integer
Dim i As Integer
For i = 10 To 99
n = Val(StrReverse(CStr(i)))
If i < n Then
If i ^ 2 = Val(StrReverse(CStr(n ^ 2))) Then
Print CStr(i) & "^2=" & CStr(i ^ 2) & Chr(9) & CStr(n) & "^2=" & CStr(n ^ 2)
End If
End If
Next i
End Sub
试题0328
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim n As Integer
n = Val(Text1.Text)
For i = 1 To n
Print Space(9 - i);
For j = 1 To i
Print "*";
Next j
Print
Next i
End Sub
试题0329
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim n As Integer
n = Val(Text1.Text)
For i = n To 1 Step -1
Print Space(9 - i);
For j = 1 To 2 * i - 1
Print "*";
Next j
Print
Next i
End Sub
试题0330
Private Sub Command1_Click()
Dim i As Integer, j As Integer
n = Val(Text1.Text)
For i = 1 To n
For j = 1 To n
If i > j Or i = j Then
Print 1;
Else
Print 0;
End If
Next j
Print
Next i
End Sub
来源:CSDN
作者:良-
链接:https://blog.csdn.net/m0_46329656/article/details/104339742