vb設計程式,統計1000以內能被7整除的正整數的個數

2021-08-04 15:43:42 字數 643 閱讀 8448

1樓:匿名使用者

private sub form_click()dim n as integer,i as integerfor i =7 to 1000

if i mod 7 = 0 then n=n+1next

print n

end sub

2樓:匿名使用者

private sub form_load()dim totali, i as integertotal = 0

i = 1

do while totali <= 1000totali = 7 * i

i = i + 1

loop

msgbox "1000以內有" & i - 2 & "個能被7整除的數"

end sub

3樓:卜馳柳卉

給你說說思路,程式就自己寫,首先能被13整除的數都是13的倍數,因此我們可以不用模運算,直接用迴圈找出13的倍數就可以了.再乙個,要求找奇數,可以把迴圈步長設為2,即step

2,這樣就可以找出這些數,然後用乙個迴圈變數計算他們的和.本人本題用do迴圈較好,可以減少執行時間.注意結束迴圈條件應該是:until

m<1000(用do迴圈的時候,n表示迴圈變數)

VFP設計程式,列印如下圖形,VFP設計程式,列印如下圖形

local n i n 5 for i 1 to n i n i say replicate n endfor 兩種bai方法 第一種 具有du通用性,修zhi 改迴圈次數dao可列印不同圖案回 clear for i 1 to 5 space 6 i for j 1 to 6 endfor end...

在vb程式設計中設計程式窗體中有文字框

option explicitdim s 9 as longprivate sub mand1 click dim i as long for i 1 to 9 paixu i next text2.text for i 0 to 9 text2.text text2.text s i next e...

用c語言設計程式求,用C語言設計乙個程式,求12345n

include stdio.h include stdlib.h int main void for sum 0,t i 1 i n sum t i printf the result is d n sum return 0 include stdio.h int jiecheng int x ma...