Post by Marisa on Sept 2, 2018 10:32:12 GMT
I'm pretty sure it's one of these.
WARNING: If you pick COBOL, make sure that you understand the following code:
WARNING: If you pick COBOL, make sure that you understand the following code:
identification division.
program-id. actualmandel.
environment division.
data division.
working-storage section.
01 template-string.
03 template-elems occurs 10 times pic x.
01 output-string.
03 output-elems occurs 97 times pic x.
local-storage section.
01 base-r pic 9(5) usage is computational-5.
01 base-i pic 9(5) usage is computational-5.
01 iter-index pic 9(5) usage is computational-5.
01 iter-div pic 9(5) usage is computational-5.
01 iter-rem pic 9(5) usage is computational-5.
01 dist2 pic S9(9)V9(9) usage is computational-5.
01 zoom pic S9(9)V9(9) usage is computational-5.
01 zr pic S9(5)V9(9) usage is computational-5.
01 zi pic S9(5)V9(9) usage is computational-5.
01 cr pic S9(5)V9(9) usage is computational-5.
01 ci pic S9(5)V9(9) usage is computational-5.
01 tr pic S9(5)V9(9) usage is computational-5.
01 ti pic S9(5)V9(9) usage is computational-5.
procedure division.
display "start"
move " .,;:|$%#@" to template-string
move 1.2 to zoom
move 0 to base-i
perform until base-i > 40
compute ci = (((base-i / 40.000) * 2.0) - 1.0) * zoom
move 0 to base-r
perform until base-r > 96
compute cr = (((base-r / 96.000) * 2.0) - 1.5) * zoom
move " " to output-elems(base-r)
perform iter-start thru iter-end
add 1 to base-r
end-perform
display output-string
add 1 to base-i
end-perform
display "done"
stop run.
iter-start.
move 0 to zr
move 0 to zi
move 0 to iter-index
perform until iter-index >= 1000
compute tr = ((zr * zr) - (zi * zi) + cr)
compute ti = ((2 * zr * zi) + ci)
move tr to zr
move ti to zi
compute dist2 = (zr * zr) + (zi * zi)
if dist2 > 4.0
go to iter-end
end-if
add 1 to iter-index
end-perform.
iter-end.
if iter-index < 1000 then
perform until iter-index < 10
subtract 10 from iter-index
end-perform
add 1 to iter-index
move template-elems(iter-index) to output-elems(base-r)
end-if
exit.