VB逆向倍数,程序运行前后都知道,求代码,高分悬赏

程序运行后如图
2024-12-30 16:12:27
推荐回答(3个)
回答1:

这样似乎符合学生水平:

Private Sub F(ByVal n As Integer, ByRef m As Integer, ByRef t As Boolean)
Dim a, b, c, d
a = n \ 1000
b = n \ 100 Mod 10
c = n \ 10 Mod 10
d = n Mod 10
m = a + b * 10 + c * 100 + d * 1000
If m > n And m Mod n = 0 And m \ n > 2 Then t = True Else t = False
End Sub

Private Sub Command1_Click()
Dim n As Integer, m As Integer, t As Boolean
For n = 1000 To 9999
Call F(n, m, t)
If t = True Then
Picture1.Print n
Picture2.Print m; "="; n; "*"; m \ n
End If
Next
End Sub

回答2:

Sub F(n As Integer, m As Integer, t As Boolean)
m = StrReverse(n)
t = ((m Mod n) = 0 And m \ n > 1)
End Sub

Private Sub Command1_Click()
Dim n As Integer, m As Integer, t As Boolean
For n = 1000 To 9999
F n, m, t
If t Then
Picture1.Print n
Picture2.Print m; "="; n; "*"; m \ n
End If
Next
End Sub

回答3:

Private Sub Command1_Click()
For i = 1000 To 9999
If StrReverse(i) Mod i = 0 And StrReverse(i) \ i >= 2 Then
Picture1.Print i
Picture2.Print StrReverse(i); "="; i; "*"; StrReverse(i) \ i
End If
Next
End Sub