周星驰 陈梦吉:跪求帮忙:关于在学习VB中的一些习题

来源:百度文库 编辑:中科新闻网 时间:2024/05/06 04:22:10
<1>编写一个过程,用来计算下列表达式的值,并输出:S=1+1/2+1/3+……+1/100

<2>编写过程,用下面的公式计算π的近似值:π/4=1-1/3+1/5-1/7+1/9-……+(-1)<n-1>[1/(2n-1)]
(那个<n-1>是(-1)的上标,表示不出来真是不好意思)
<3>用随机函数产生20个两位数,按小到大的顺序输出.

谢谢各位大虾指点小弟一下,小弟将感激不尽~~
小弟在线跪等各位大侠啊!

<1>
sub PrintS()
dim i as integer,s as single
for i= 1 to 100
s=s+1/i
next i
print s
end sub
<2>
Sub PrintTT(dim n as integer)
TT as single
TT=4*((-1)^(n-1))*(1/(2*n-1))
print TT
end sub
<3>
dim a(20) as integer
dim i as integer,j as integer
for i=1 to 20
a(i)=int(rnd*90)+10
next i
for i=1 to 19
for j= i+1 to 20
If a(j) < a(i) Then
m = a(i)
a(j) = a(i)
a(i) = m
end if
next j
next i
for i= 1 to 20
print a(i)
next i