主题:qb难点
高精度求FIBONACI第n项与前n项之和.BASCLS
INPUT "n=", n
DIM a(200), b(200), c(201), s(201)
a(1) = 1
b(1) = 1
s(1) = 2
FOR i = 3 TO n
jw = 0
FOR j = 1 TO 200
c(j) = a(j) + b(j) + jw
jw = c(j) \ 10
c(j) = c(j) MOD 10
NEXT
jw = 0
FOR j = 1 TO 200
s(j) = s(j) + c(j) + jw
jw = s(j) \ 10
s(j) = s(j) MOD 10
NEXT
FOR j = 1 TO 200
a(j) = b(j)
b(j) = c(j)
NEXT
NEXT
i = 201
DO WHILE c(i) = 0
i = i - 1
LOOP
y = 201
DO WHILE s(y) = 0
y = y - 1
LOOP
PRINT "di n xiang wei:";
FOR j = i TO 1 STEP -1
PRINT USING "#"; c(j);
NEXT
PRINT
PRINT "qian n xiang zhi he shi :"
FOR j = y TO 1 STEP -1
PRINT USING "#"; s(j);
NEXT
END
[fly]我认为难点是这个[/fly]
[fly]请问还有哪些呢?[/fly]
INPUT "n=", n
DIM a(200), b(200), c(201), s(201)
a(1) = 1
b(1) = 1
s(1) = 2
FOR i = 3 TO n
jw = 0
FOR j = 1 TO 200
c(j) = a(j) + b(j) + jw
jw = c(j) \ 10
c(j) = c(j) MOD 10
NEXT
jw = 0
FOR j = 1 TO 200
s(j) = s(j) + c(j) + jw
jw = s(j) \ 10
s(j) = s(j) MOD 10
NEXT
FOR j = 1 TO 200
a(j) = b(j)
b(j) = c(j)
NEXT
NEXT
i = 201
DO WHILE c(i) = 0
i = i - 1
LOOP
y = 201
DO WHILE s(y) = 0
y = y - 1
LOOP
PRINT "di n xiang wei:";
FOR j = i TO 1 STEP -1
PRINT USING "#"; c(j);
NEXT
PRINT "qian n xiang zhi he shi :"
FOR j = y TO 1 STEP -1
PRINT USING "#"; s(j);
NEXT
END
[fly]我认为难点是这个[/fly]
[fly]请问还有哪些呢?[/fly]