Vb中的for循环问题?
1/x-2/x'2+3/x'3-4/x'4......n/x'n(直到最后一项小于0.000001为止)...
1/x-2/x'2+3/x'3-4/x'4......n/x'n(直到最后一项小于0.000001为止)
展开
3个回答
展开全部
privite sub form1_click()
dim sum as single,d as single,x as single
dim n as integer
sum=0
do
x=val(input("输入","x的值(x>1)",2))
loop while x<=1
for n=1 to 10000
d=n/(x^n)
sum=sum+d
if d<1E-6 then exit for
next
print "n=";n,"sum="; sum
end sub
有什么问题请留言。
dim sum as single,d as single,x as single
dim n as integer
sum=0
do
x=val(input("输入","x的值(x>1)",2))
loop while x<=1
for n=1 to 10000
d=n/(x^n)
sum=sum+d
if d<1E-6 then exit for
next
print "n=";n,"sum="; sum
end sub
有什么问题请留言。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim i as integer,v as double,sum as double
dim x as double
x=2:i=1
v = i/x ^i
do while v>0.000001
if i mod 2=1 then sum = sum+v
if i mod 2 =0 then sum = sum - v
i=i+1
v = i/x ^i
loop
dim x as double
x=2:i=1
v = i/x ^i
do while v>0.000001
if i mod 2=1 then sum = sum+v
if i mod 2 =0 then sum = sum - v
i=i+1
v = i/x ^i
loop
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个问题中的x1片,还有一个数字,这是表示什么意思呢?希望能够讲清楚,然后才能够编写程序的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询