1樓:
1:dim i as integer
dim s as double
dim s0 as double
for i = 1 to 100
s0 = 1 / i
if i mod 2 = 0 then s0 = s0 * (-1)s = s + s0
next
print s
2:dim i as integer
dim s as double
for i = 1 to 100 step 2s = s + 1 / i - 1 / (i + 1)next
print s
3:dim i as integer
dim s as double
i = 1
do until i >= 100
s = s + 1 / i - 1 / (i + 1)i = i + 2
loop
print s
4:dim i as integer
dim s as double
for i = 1 to 100
select case i mod 2
case 0
s = s - 1 / i
case 1
s = s + 1 / i
end select
next
print s
c語言程式設計計算1-1/2+1/3-1/4+...+1/99-1/100 5
2樓:匿名使用者
for語句下面加,也就是說你的for迴圈主體少了{}括號,這樣子的話,實際迴圈主體就只有k=-k這一句了。
3樓:匿名使用者
for迴圈少了大括號
for(i=2;i<=100;i++)
vb程式設計題,vb程式設計題目
dim a 1 to 80 as integer dim js as integer dim os as integer private sub command1 click dim i,j,k randomize j 0 text1.text for i 1 to 80 a i int rnd 9...
VB程式設計題目,vb程式設計題目
給郵箱,發工程,以免自己除錯不出來 private sub command1 click timer1.enabled true end sub private sub command2 click timer1.enabled false timer2.enabled true label1.ca...
Vb程式設計,什麼是VB程式設計?
private sub command1 click dim a 1 to 100 as integer,b as integer dim i as integer,j as integer,n as integer randomize timer for i 1 to 100 a i int rn...