vb的小题来求解。谢谢哥哥姐姐,美女帅哥

来源:百度知道 编辑:UC知道 时间:2024/07/07 06:27:19
在一个三位数中 要求个位,十位,百位的立方和相加等于这个三位数

dim a as long
dim b as long
dim temp1 as long
dim temp2 as long
dim temp3 as long

for a = 100 to 999
temp1=(a\100)*(a\100)*(a\100)
temp2=mod(a\10,10)*mod(a\10,10)*mod(a\10,10)
temp3=mod(a,10)*mod(a,10)*mod(a,10))
if a = temp1+temp2+temp3 then
msgbox(a)
end if
next

for i=1000 to 999
a=val(mid(str(i),1,1))
b=val(mid(str(i),2,1))
c=val(mid(str(i),3,1
if a*a*a+b*b*b+c*c*c=i then print i
next

楼上的打错了吧,修改哈
for i=100 to 999
a=val(mid(str(i),1,1))
b=val(mid(str(i),2,1))
c=val(mid(str(i),3,1
if a*a*a+b*b*b+c*c*c=i then print i
next

for I=1 to 9
for j=0 to 9
for k=0 to 9
if I*I*I+J*J*J+K*K*K=I*100+j*10+k then
print I*100+j*10+k
end if
next
next
next

具体代码自己去完善.

For i = 100 To 999
If Mid(i, 1, 1) ^ 3 + Mid(i, 2, 1) ^ 3 + Mid(i, 3, 1)