China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 19:48
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Question about a QB program View 1,462 Replies 7
Original Poster Posted 2002-11-22 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
初级用户
Credits 172
Posts 22
Joined 2002-11-04 00:00
23-year member
UID 155
Gender Male
Status Offline
Can I ask questions about QB?


Floor 2 Posted 2002-11-22 00:00 ·  中国 广东 佛山 禅城区 电信
元老会员
★★★★
Credits 5,170
Posts 1,637
Joined 2002-10-16 00:00
23-year member
UID 8
Gender Male
From 广东佛山
Status Offline
Yes, it's QBASIC, right.
我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
Floor 3 Posted 2002-11-22 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 172
Posts 22
Joined 2002-11-04 00:00
23-year member
UID 155
Gender Male
Status Offline
Here's a question: “2/1,3/2,5/3,5/8,13/8,21/13.... find the sum of the first 20 terms of this sequence” How should this be coded?
cls
a=1:b=1:m=0
for i= 1 to 20
a=a+b
m=m+a/b
b=a
next i
print m
The output is 40. Where is the mistake?
Floor 4 Posted 2002-11-22 00:00 ·  中国 广东 佛山 禅城区 电信
元老会员
★★★★
Credits 5,170
Posts 1,637
Joined 2002-10-16 00:00
23-year member
UID 8
Gender Male
From 广东佛山
Status Offline
Your program is wrong. I worked it out, and when i=1, the formula is correct,
a=a+b=2 ;m=m+2/1
But when i=2 it's no longer right. Because earlier b=a, so b=2; at this time this term's a+b=4,
m=m+4/2.
Work it out and see
我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
Floor 5 Posted 2002-11-22 00:00 ·  中国 广东 佛山 禅城区 电信
元老会员
★★★★
Credits 5,170
Posts 1,637
Joined 2002-10-16 00:00
23-year member
UID 8
Gender Male
From 广东佛山
Status Offline
Try coding it like this:
cls
a=2:b=1:m=0
for i= 1 to 20
m=m+a/b
t=a+b
b=a
a=t
next i
print m
我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
Floor 6 Posted 2002-11-22 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 172
Posts 22
Joined 2002-11-04 00:00
23-year member
UID 155
Gender Male
Status Offline
Could I trouble you to write out the correct one? I've been thinking about it for a long time already~ boohoohoo
Floor 7 Posted 2002-11-23 00:00 ·  中国 广东 佛山 禅城区 电信
元老会员
★★★★
Credits 5,170
Posts 1,637
Joined 2002-10-16 00:00
23-year member
UID 8
Gender Male
From 广东佛山
Status Offline
Isn't the program I gave already the correct one?
我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
Floor 8 Posted 2002-11-23 00:00 ·  中国 广东 东莞 电信
初级用户
Credits 172
Posts 22
Joined 2002-11-04 00:00
23-year member
UID 155
Gender Male
Status Offline
Thank you so, so much~
Forum Jump: