帮忙解决3道VB题 谢谢了

来源:百度知道 编辑:UC知道 时间:2024/05/04 06:19:24
1.设a,b,c是同一类型变量,并分别赋予不同大小的数据,设计一个算法,使得执行的结果a>b>c.
2.设计一个可以判断某数是否是素数的算法(素数是指只能被1和自身整除的数)
3.设计判断某正数是回文数的算法(回文数指左右数字完全对称的数,如12321,282,555)

1.

Dim a As Long, b As Long, c As Long '原数
Dim a2 As Long, b2 As Long, c2 As Long '排序后数
'最大
a2 = a
If a2 < b Then a2 = b
If a2 < c Then a2 = c
a = i
'中
b2 = a
If b < a And b > c Then b2 = b
If c < a And c > b Then b2 = c
'最小
c2 = a
If a2 > b Then a2 = b
If a2 > c Then a2 = c

a = a2
b = b2
c = c2

2.
Private Function sushu(ByVal n As Long) As Boolean
Dim i As Long

For i = 2 To Int(Sqr(m))
If (n Mod i) = 0 Then Exit For
Next i
If i = n Then sushu = True
End Function

3.
Dim str As String
If str = StrReverse(str) Then
MsgBox "回文数"
End If