一个两位数的正整数,如果将其个位数与十位数对调所生成的数称为对调数,如28是82的对调数.现给定一个两Dim a As Integer,b As Integer,c As IntegerDim d As Integer,e As String,f As StringPrivate Sub Command1_Click()f
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 17:22:30
一个两位数的正整数,如果将其个位数与十位数对调所生成的数称为对调数,如28是82的对调数.现给定一个两Dim a As Integer,b As Integer,c As IntegerDim d As Integer,e As String,f As StringPrivate Sub Command1_Click()f
一个两位数的正整数,如果将其个位数与十位数对调所生成的数称为对调数,如28是82的对调数.现给定一个两
Dim a As Integer,b As Integer,c As Integer
Dim d As Integer,e As String,f As String
Private Sub Command1_Click()
f = InputBox("请输入一个两位数")
a = Val(f)
b = Val(Right(f,1)) * 10 + Val(Left(f,1))
c = 9
Do Until c >= 100
c = c + 1
e = Str(c)
d = Val(Right(e,1)) * 10 + Val(Left(e,1))
If a + b = c + d Then
Print a,b,c,d
End If
Loop
End Sub
为什么这个程序print输出为空?
一个两位数的正整数,如果将其个位数与十位数对调所生成的数称为对调数,如28是82的对调数.现给定一个两Dim a As Integer,b As Integer,c As IntegerDim d As Integer,e As String,f As StringPrivate Sub Command1_Click()f
没有满足你的表达式的数呗
看一下你的表达式错没有?
If a + b = c + d Then
笑年1977答案是错的,结果只是两个数对调位置而已,比如23+32=32+23,结果这个。
应该这样才可以
Private Sub Form_Click()
Me.Cls
Dim Num As Integer, i As Integer
Do
Num = Int(Val(InputBox("输入2位数")))
Loop While Len(C...
全部展开
笑年1977答案是错的,结果只是两个数对调位置而已,比如23+32=32+23,结果这个。
应该这样才可以
Private Sub Form_Click()
Me.Cls
Dim Num As Integer, i As Integer
Do
Num = Int(Val(InputBox("输入2位数")))
Loop While Len(CStr(Num)) <> 2
For i = 10 To 99
If Num + i = Chg(Num) + Chg(i) Then Print Num, i
Next i
End Sub
Private Function Chg(N As Integer) As Integer
Chg = Mid(CStr(N), 2, 1) & Mid(CStr(N), 1, 1)
End Function
收起
If (a + b )== (c + d )Then