vb编写程序找灵巧数编写vb程序,找出给定范围内所有的回文数

2021-03-07 11:59:09 字数 5711 阅读 1675

1楼:匿名用户

'其实不难,运行效果如

上,**如下

'若要判断三位数、四位数、五位数……以内的略改一下**即可'有问题可找我

privatesub***mand1_click()dimiasinteger

dima,basinteger

dimnasdouble

print"100以内的灵巧数有:"

fori=1to99

a=int(i/10)'取十位

b=imod10'取个位

n=sqr(i+(b*10+a))ifint(n)=nthen'判断n是否为整数printi

endif

nexti

endsub

2楼:匿名用户

innodb_data_home_dir = /longxibendi/mysql/mysql/var/

#innodb_data_file_path = ibdata1:1g:autoextend

innodb_data_file_path = ibdata1:500m;ibdata2:2210m:autoextend #表空间

innodb_file_io_threads = 4 #io线程数

vb编写程序找灵巧数

3楼:庆年工坊

subs()

fori=10to99

a=sqr(i+(imod10)*10+i\10)

ifint(a)=athenprinti;

next

endsub

编写vb程序,找出给定范围内所有的回文数

4楼:匿名用户

privatesub***mand1_click()dimaasstring,nasinteger,iasinteger

a=text1.text

n=len(a)

fori=1ton

ifmid(a,i,1)<>mid(a,n-i+1,1)thenexitfor

nexti

ifi=n+1then

print"是回文数

"else

print"不是回文数"

endif

endsub

5楼:刘师傅的一生

回文?都不知道你在说什么,我要举报你

求vb高手:编写程序,找出10000~99999的所有回文数!

6楼:匿名用户

private sub ***mand1_click()dim i as long, j as longdim x1 as long, x2 as longdim str as string

dim flag as boolean

str = "从 10000 到 99999 之间的回文数有:" & vbcrlf

for i = 10000 to 99999flag = 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

7楼:匿名用户

dim str as string

dim i as integer

dim j as integer

dim k as integer

dim l as integer

dim hwdata(899) as integerl=0for 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中保存得是所有得回文数据

8楼:匿名用户

把这些数的个位,十位。百位,千位,万位分别用变量保存起来,只要对比个位跟万位相等,同时十位跟千位相等的就是了。

9楼:桑嫒运昕

楼上有点投机取巧的嫌疑哦,呵呵~~~也试试下面这个啦:

dima

asinteger,bas

integer,cas

integer

fora=1

to9forb=0

to9forc=0

to9printa&

b&c&

b&anext

**ext

bnexta

编制vb程序,找出1--1000之间的全部“完备数”

10楼:匿名用户

添加一个按钮

**如下:

private sub ***mand1_click()

dim perfect as string

for i = 1 to 1000

if isperfect(i) = true then '如果i完备数

perfect = perfect & "," & i '将所有的完备数存放在字符串里

end if

next i

msgbox "1到1000的完备数有:" & mid(perfect, 2, len(perfect) - 1) '输出完备数

end sub

function isperfect(byval n as long) as boolean '判断是否为完备数

dim i as long

dim x as long

for i = 1 to int(n / 2)

if n mod i = 0 then

x = x + i

end if

next

if x = n then

isperfect = true

else

isperfect = false

end if

end function

结果如下:

1到1000的完备数有:6,28,496

11楼:喝多了跑偏

两个函数,一个找约数,一个做for循环,然后测试。

vb编写function过程,判断数字是否是回文数。程序要求输入一系列数字,找出所有的回文数并显示在文本框中 50

12楼:网海1书生

private sub ***mand1_click()dim x as long, a as integerfor a = 1 to 5

x = val(inputbox("请输入一个整数"))if fac(x) then text1.text = text1.text & x & " "

next

end sub

function fac(x as long) as booleanfac = (x = val(strreverse(x)))end function

怎么样,我这函数只用一行语句就解决了!原理就是把一个数左右反转,如果与原来的数相等,那么就是回文数。

用vb编写程序,找出所有小于或等于100的自然数对。

13楼:匿名用户

private sub form_activate()dim i%, j%, x%, y%

for i = 1 to 100

for j = 1 to i

x = i + j

y = i - j

if y > 0 then

if sqr(x) = int(sqr(x)) and sqr(y) = int(sqr(y)) then

print i, j

end if

end if

next j

next i

end sub

vb设计一个程序:找出1~9999之间的全部的同构数

14楼:灰色

publicfunctionlength(byvalresasinteger)asinteger

length=0

dores=res/10

length=length+1

loopwhileres<>0

endfunction

publicfunctionisisomorphic(byvalnumasinteger)asboolean

pow=num^2

mult=1

fori=1tolength(num)

mult=mult*10

ifpowmodmult=numthen

isisomorphic=ture

else

isisomorphic=false

endif

next

endfunction

publicsubjudge()

fori=1to9999

ifisisomorphic(i)thendebug.printi;" ";i*i

endif

next

endsub

这个不难,复制上去的时候不知道空格有没有出来

15楼:匿名用户

dim i as long

dim l as integer

dim j as long

for i = 1 to 9999

j = i * i

l = len(cstr(i))

if right(cstr(j), l) = cstr(i) then debug.print i

next i

16楼:仁晏五淑然

#include

intmain()}

用vb编写程序(找出三个数中的最大数,通过inputbox函数获得三个数)

17楼:匿名用户

private sub ***mand1_click()dim a as single

dim b as single

dim c as single

dim max as single

a = val(inputbox("输入第1个数"))max = a

b = val(inputbox("输入第2个数"))if b > max then max = bc = val(inputbox("输入第3个数"))if c > max then max = cmsgbox "最大数是" & max

end sub