private sub command1_click()
dim m as integer, n as integer, d as integer
dim s as long '
儲存結果
m = val(text1.text)
n = val(text2.text)
d = val(text3.text)
s = 0
sum m, n, d, s
label4.caption = m & "
到" & n & "
之間能被
" & d & "
整除的數之和是
" & s
end sub
private sub command2_click()
end
end sub
'sub
過程:求m到
n之間能
d被整除的數之和
public sub sum(x as integer, y as integer, z as integer, w as long)
dim i as integer '
若x>y,
交換if x > y then
t = x: x = y: y = t
end if
for i = x to y
if i mod z = 0 then
w = w + i
end if
next i
end sub
private sub text1_keypress(keyascii as integer)
if not isnumeric(chr(keyascii)) and keyascii <> 8 then
keyascii = 0
end if
end sub
private sub text2_keypress(keyascii as integer)
if not isnumeric(chr(keyascii)) and keyascii <> 8 then
keyascii = 0
end if
end sub
private sub text3_keypress(keyascii as integer)
if not isnumeric(chr(keyascii)) and keyascii <> 8 then
keyascii = 0
end if
end sub
判斷整除並求和
private sub command1 click dim m as integer,n as integer,d asinteger dim s as long 儲存結果 m val text1.text n val text2.text d val text3.text s 0 sum m,n...
1195 判斷整除
題目描述 乙個給定的正整數序列,在每個數之前都插入 號或 號後計算它們的和。比如序列 1 2 4共有8種可能的序列 1 2 4 7 1 2 4 1 1 2 4 3 1 2 4 5 1 2 4 5 1 2 4 3 1 2 4 1 1 2 4 7 所有結果中至少有乙個可被整數k整除,我們則稱此正整數序列...
1195 判斷整除
1195 判斷整除 時間限制 1000 ms 記憶體限制 65536 kb 題目描述 乙個給定的正整數序列,在每個數之前都插入 號或 號後計算它們的和。比如序列 1 2 4共有8種可能的序列 1 2 4 7 1 2 4 1 1 2 4 3 1 2 4 5 1 2 4 5 1 2 4 3 1 2 4 ...