1樓:大野瘦子
**為:
dim i as integer, m as integer, n as integer, sum as integer, p as integer
m = val(text1.text)
n = val(text2.text)
sum = 0
for p = m to n
for i = 2 to p - 1
if (p mod i) = 0 thenexit for
end if
next i
if p = i then
sum = sum + p
end if
next p
text3.text = str(sum)注意事項
m到n以內的素數
#include
using namespqce std;
bool isprime(int n)
return true;
}vectormtonprime(int m, int n)return aprime;
} int main()
cout << endl;
return 0;}
2樓:匿名使用者
'求符合條件的素數之和,條件:m≤素數≤n ,在vb6環境中除錯通過。
private sub ***mand1_click()form1.cls
dim s as long
dim a as long, b as long, c as boolean
dim j as long, k as longj = val(text1)
k = val(text2)
for a = j to k
c = false
for b = a - 1 to 2 step -1if a mod b = 0 then
c = true
's = s + b
exit for
end if
next b
if c = false then s = s + anext a
text3 = s
end sub
3樓:落葉愁空山
dim i as integer, m as integer, n as integer, sum as integer, p as integer
m = val(text1.text)
n = val(text2.text)
sum = 0
for p = m to n
for i = 2 to p - 1
if (p mod i) = 0 thenexit for
end if
next i
if p = i then
sum = sum + p
end if
next p
text3.text = str(sum)
4樓:匿名使用者
private sub form_click()form1.cls
dim s as long
dim a as long, b as long, c as boolean
dim j as long, k as longdim n as integer
j=val(text1)
k=val(text2)
for a = j to k
c = false
for b = a - 1 to 2 step -1if a mod b = 0 then
c = true
s = s + b
exit for
end if
next b
if c = false then
n = n + 1
if n mod 5 = 0 then
print a
else
print a:
end if
end if
next a
text3= s
end sub
5樓:我是實誠人誒
完全不懂什麼意思 ··
vb程式設計中,怎樣編寫輸入兩個數m和n,求大於m的n個素數的**??? 30
6樓:山水阿銳
您好,這樣的:
dim m as integer, n as integerprivate sub ***mand1_click()m = val(inputbox("輸入正整數"))n = val(inputbox("輸入正整數"))if n * m = 0 then
msgbox "兩數任何乙個數都不能為0!"
exit sub
end if
end sub
private sub ***mand2_click()dim r as integer, s as integerr = m: s = 1
do until m mod r = 0 and n mod r = 0 '最大公約數
r = r - 1
loop
do until s mod m = 0 and s mod n = 0 '最小公倍數
s = s + 1
loop
text1.text = "最大公約數是:" & r & "最小公倍數是:" & s
end sub
vb程式設計中,怎樣編寫輸入兩個數m和n,求大於m的n個素數的**?要求顯示出這n個素數
7樓:匿名使用者
private sub ***mand1_click()dim i, j, str, n as integera = val(text1.text)
b = val(1000)
n = 0
for i = a to b
swit = 1 1為素數
for j = 2 to i - 1
if i mod j = 0 then '其實du不用平方,有
zhi乙個被整除就dao為0
swit = 0
end if
next j
if swit = 1 then
str = str i '用表示將輸
回出的字元連
答起來n = n + 1
if n = val(text2.text) thengoto '有n個就結束
end sub:
end if
end if
next i
print str
end sub
8樓:匿名使用者
您好,需要及時上醫院處理的.不然容易引起大出血的.有什麼不明白的,歡迎繼續提問.
vb求 整數n到m間的所有數之和(n
9樓:互相學習中
1 dim
2 0 ……數字0
3 s+i
4 i就這四個空,填上就好
vb編寫程式,輸入整數m和n,計算m和n的公約數之和
10樓:匿名使用者
public function gy() as integerdim m, n, sum, t as integerm = inputbox("輸入第bai乙個自du然zhi數")n = inputbox("輸入第二
dao個自然數")
sum = 0
if m < n then t = m : m = n : n = t
for i = 1 to n
if m mod i = 0 and n mod i = 0 then
sum = sum + i
end if
next
return sum
end function
11樓:匿名使用者
dim m,n as long m = inputbox("請輸入du非zhi
負整dao數版
權m", "輸入", "0") n = inputbox("請輸入非負整數n", "輸入", "0") if m >= 0 and n >= 0 then if m >= n then msgbox "m = " & m & ...
vb求10 1000之間的所有完數之和
dim a as integer,b as integer,s as integer,y as integer s 0 for a 10 to 1000 b 0 for y 1 to a 1 if a mod y 0 then b b ynext y if b a then s s anext a ...
vb程式設計中怎樣編寫輸入兩個數m和n求大於m的n個
您好,這樣的 dim m as integer,n as integerprivate sub mand1 click m val inputbox 輸入正整數 n val inputbox 輸入正整數 if n m 0 then msgbox 兩數任何乙個數都不能為0 exit sub end i...
Vb程式設計中,怎樣編寫輸入兩個數m和n,求大於m的n個素數的代
private sub command1 click dim i,j,str,n as integera val text1.text b val 1000 n 0 for i a to b swit 1 1為素數 for j 2 to i 1 if i mod j 0 then 其實du不用平方,...