求出1 100之間的完全數及其累加和,並輸出窗體上。用vb編

2022-12-19 10:16:14 字數 1194 閱讀 1553

1樓:匿名使用者

'求出1—100之間的完全數及其累加和,並輸出窗體上。用vb編寫const m as long = 100dim i as long, j as long, k as long

dim a as long, b as long, c as long

b = 0

c = 0

for a = 1 to m

k = int(a / 2)

j = 0

for i = 1 to k

if a mod i = 0 then j = j + inext i

if a = j then

b = b + 1

c = c + a

print a '輸出所有合要求的完全數

end if

next a

msgbox "1到" & cstr(m) & "之間共有" & cstr(b) & "個完全數,他們的和為" & cstr(c)

'剛做了一題是要1到1000的,把m改成1000就行。

2樓:寒信

private sub command1_click()dim i as integer, j as integer, a() as integer, s as integer

for i = 2 to 100

redim a(0)

for j = 1 to i - 1

if i mod j = 0 then

redim preserve a(ubound(a) + 1)a(ubound(a)) = j

end if

next j

s = 0

for j = 1 to ubound(a)s = s + a(j)

next

if s = i then

print i;

for j = 1 to ubound(a)if j = 1 then

print "=" & a(j);

else

print "+" & a(j);

end if

next j

print

end if

next i

end sub

private sub form_load()me.autoredraw = true

end sub

用sql求出,用sql求出1 100之間所有能被3整除的個數和所有能被2整除的個數,並將答案輸出

create table number num int delete from numberinsert number values 1 insert number values 2 insert number values 3 insert number values 4 insert numbe...

用pascal語言找出1 100之間的孿生漂亮數

請先告訴我什麼是孿生漂亮數 type node record z,n longint end vari,r,j longint b array 0.1000,0.1 of longint procedure find ans longint vari,p longint a array 1.100 ...

呼叫FUN函式的功能是。求出1到m之間能被7或11整除的所有

int fun int m,int a return n int fun int m retrun n int fun int m,int im return im 0 define m 1000 int fun int m return n int main 編寫函式fun,其功能是 將所有大於1...