真的没人打下面那个180分的题吗?这里再补200分
来源:百度知道 编辑:UC知道 时间:2024/05/17 03:51:38
楼上的全注意了,正确答案来了,分数我要了
此代码只需添加两个 command按钮到窗体既可
Private Sub Command1_Click() '求素数
Form1.AutoRedraw = True
Dim a, b As Integer
Dim n As Integer
n = InputBox("请输入一个正整数")
For a = 3 To n
b = 2
Do Until a Mod b = 0
b = b + 1
If b = a Then
Print a & " 是素数"
Exit Do
End If
Loop
Next a
End Sub
Private Sub Command2_Click() '求完全数
Form1.AutoRedraw = True
Dim a, b, c, n As Integer
Dim n As Integer
n = InputBox("请输入一个正整数")
For a = 2 To n
c = 0
For b = 1 To a - 1
If a Mod b = 0 Then
c = c + b
End If
Next
If a = c Then
Print a & " 是完全数"
End If
Next
En