求VB高手:编写程序,找出10000~99999的所有回文数!
答案:3 悬赏:70 手机版
解决时间 2021-04-13 00:23
- 提问者网友:战魂
- 2021-04-12 10:46
求VB高手:编写程序,找出10000~99999的所有回文数!
最佳答案
- 五星知识达人网友:渊鱼
- 2021-04-12 11:13
Private Sub Command1_Click()
Dim I As Long, J As Long
Dim X1 As Long, X2 As Long
Dim str As String
Dim Flag As Boolean
str = "从 10000 到 99999 之间的回文数有:" & vbCrLf
For I = 10000 To 99999
Flag = False
For J = 1 To Len(CStr(I))
If Mid(CStr(I), J, 1) <> Mid(CStr(I), Len(CStr(I)) - J + 1, 1) Then
Flag = True
Exit For
End If
Next J
If Flag = False Then str = str & I & " "
Next I
MsgBox str
End Sub
Dim I As Long, J As Long
Dim X1 As Long, X2 As Long
Dim str As String
Dim Flag As Boolean
str = "从 10000 到 99999 之间的回文数有:" & vbCrLf
For I = 10000 To 99999
Flag = False
For J = 1 To Len(CStr(I))
If Mid(CStr(I), J, 1) <> Mid(CStr(I), Len(CStr(I)) - J + 1, 1) Then
Flag = True
Exit For
End If
Next J
If Flag = False Then str = str & I & " "
Next I
MsgBox str
End Sub
全部回答
- 1楼网友:你哪知我潦倒为你
- 2021-04-12 12:56
把这些数的个位,十位。百位,千位,万位分别用变量保存起来,只要对比个位跟万位相等,同时十位跟千位相等的就是了。
- 2楼网友:低音帝王
- 2021-04-12 12:11
dim str as string
dim i as integer
dim j as integer
dim k as integer
dim l as integer
dim hwdata(899) as integer
l=0
for i=1 to 9
for j=0 to 9
for k=0 to 9
str=trim(str(i)) & trim(str(j)) & trim(str(k)) & trim(str(j)) & trim(str(i))
hwdata(l)=val(str)
l=l+1
next k
next j
next i
hwdata中保存得是所有得回文数据
dim i as integer
dim j as integer
dim k as integer
dim l as integer
dim hwdata(899) as integer
l=0
for i=1 to 9
for j=0 to 9
for k=0 to 9
str=trim(str(i)) & trim(str(j)) & trim(str(k)) & trim(str(j)) & trim(str(i))
hwdata(l)=val(str)
l=l+1
next k
next j
next i
hwdata中保存得是所有得回文数据
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯