所谓回文数是从左至右与从右至左读起来都是一样的数字,如:121是一个回文数。编写程序,求在100-900的范围内所有能被3整除的回文数的个数。
所谓回文数是从左至右与从右至左读起来都是一样的数字,如:121是一个回文数。编写程序,求在100-900的范围内所有能被3整除的回文数的个数。
Private Sub Command1_Click()
Dim I As Integer, J As Integer, S As Integer, T As Integer
For I = 100 To 900
T = (I Mod 10) * 100 + (I \ 10 Mod 10) * 10 + I \ 100
If T = I And I Mod 3 = 0 Then Print I
Next
End Sub
'借代码以用,人家要求个数,不是全写出来
Private Sub s1()
Dim I As Integer, J As Integer, S As Integer, T As Integer
Dim k as integer
k=0
For I = 100 To 900
T = (I Mod 10) * 100 + (I \ 10 Mod 10) * 10 + I \ 100
If T = I And I Mod 3 = 0 Then k=k+1
Next
msgbox "从100-199之间能被3整除的回文数有" & k & "个!"
End Sub