31 lines
498 B
Plaintext
31 lines
498 B
Plaintext
' Trabb Pardo-Knuth algorithm
|
|
' Used "magic numbers" because of strict specification of the algorithm.
|
|
dim s(10)
|
|
print "Enter 11 numbers."
|
|
for i = 0 to 10
|
|
print i + 1;
|
|
input " => "; s(i)
|
|
next i
|
|
print
|
|
' Reverse
|
|
for i = 0 to 10 / 2
|
|
tmp = s(i)
|
|
s(i) = s(10 - i)
|
|
s(10 - i) = tmp
|
|
next i
|
|
'Results
|
|
for i = 0 to 10
|
|
print "f("; s(i); ") = ";
|
|
r = f(s(i))
|
|
if r > 400 then
|
|
print "overflow"
|
|
else
|
|
print r
|
|
end if
|
|
next i
|
|
end
|
|
|
|
function f(n)
|
|
f = sqr(abs(n)) + 5 * n * n * n
|
|
end function
|