vb 守型数 设A为一个整数,如果a^2=x*a,成立,则称a为 守型数,如5^2=25,25^=625,求1-1000
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/11/06 01:43:49
vb 守型数 设A为一个整数,如果a^2=x*a,成立,则称a为 守型数,如5^2=25,25^=625,求1-1000守型数
Public Function fun1(a As Long)
Dim b As Single,c As Single,n As Integer,d As Long
n = 1
b = a / 10
While b >= 1
n = n + 1
b = a / (10 ^ n)
Wend
c = (a ^ 2 - a) / (10 ^ n)
If Fix(c) = c Then
d = a
End If
fun1 = d
End Function
调用时:
Private Sub Form_Click()
Dim a As Long
For a = 1 To 1000
r = fun1(a)
Print fun1(a);
Next a
End Sub
为什么不对呢?
Public Function fun1(a As Long)
Dim b As Single,c As Single,n As Integer,d As Long
n = 1
b = a / 10
While b >= 1
n = n + 1
b = a / (10 ^ n)
Wend
c = (a ^ 2 - a) / (10 ^ n)
If Fix(c) = c Then
d = a
End If
fun1 = d
End Function
调用时:
Private Sub Form_Click()
Dim a As Long
For a = 1 To 1000
r = fun1(a)
Print fun1(a);
Next a
End Sub
为什么不对呢?
对的.仅仅有点小问题.
Public Function fun1(a As Long)
Dim b As Single, c As Single, n As Integer, d As Long
n = 1
b = a / 10
While b >= 1
n = n + 1
b = a / (10 ^ n)
Wend
c = (a ^ 2 - a) / (10 ^ n)
If Fix(c) = c Then
d = a
End If
fun1 = d
End Function
'调用时:
Private Sub Form_Click()
Dim a As Long
For a = 1 To 1000
r = fun1(a)
If r = a Then Print fun1(a);
Next a
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
End Su
Public Function fun1(a As Long)
Dim b As Single, c As Single, n As Integer, d As Long
n = 1
b = a / 10
While b >= 1
n = n + 1
b = a / (10 ^ n)
Wend
c = (a ^ 2 - a) / (10 ^ n)
If Fix(c) = c Then
d = a
End If
fun1 = d
End Function
'调用时:
Private Sub Form_Click()
Dim a As Long
For a = 1 To 1000
r = fun1(a)
If r = a Then Print fun1(a);
Next a
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
End Su
vb 守型数 设A为一个整数,如果a^2=x*a,成立,则称a为 守型数,如5^2=25,25^=625,求1-1000
当x∈a,若x-1不∈A,x+1不∈A,则称x为A的一个“孤立元素’求集合A=﹛0,1,2,3,5﹜中‘孤立元素’组..
设集合I={1,2,3,4,5},A与B是I的子集,若A∩B={4,5},则称(A,B)为一个“完美配集”,如果A≠B,
(1/2)VB编程,如果一个三位整数等于其各位数字的立方和,则称这个数为水仙花数,如153=1^3+5...
集合A={1,2,3,5},当x∈A时,若x-1∉A且x+1∉A,则称x为A的一个“孤立元素”,则A中孤立元素的个数为_
ax²+2(2a-1)x+4(a-3)=0至少有一个整数根 a为整数 求所有的a
已知不等式5x-2<6x+1成立的最小整数值为方程2x-ax=4的解,求a的值
设a,b为整数,关于x的方程x^2+ax+b=0有一个根是2减根3,求a+b的值
设a、b都是整数,关于x的方程x^2+ax+b=0有一个根为2-根号3,求a+b的值
设a,b为整数,关于x的方程x的平方+ax+b=0有一个根是2减根3,求a+b的值
集合U={0,1,2,3,4,5},A是U的子集,当x属于A时,若有x-1不属于A,则称x为A的一个“孤立元素”,求U的
设x=2+根号3,x的整数部分为a,小数部分为b,求b-根号3+1/a+b的值