[問題] loop的用法
小弟這學期剛學fortran
program Fibonacci
implicit none
integer :: fn0, fn1, fn, count, number, loop
print *, "Which Fabonacci number you what to find?"
read *, number !The number is the nth Fabonacci nuber that need to find.
Note that 0 is the zeroth termbut not the first.
fn0 = 0
fn1 = 1
if ( number > 46) then
number = 46
print *, ""
print *, "The 47th number and onwards are too big for the computer to
calculate. Only 46 terms will be displayed."
end if
loop = number - 1
print *, ""
print *, "The numbers are:"
loop0 : do
print *, "0", fn0
if ( number == 0 ) stop
loop1 : do
print *, "1", fn1
if ( number == 1 ) stop
loopfn : do count = 1, loop
fn = fn0 + fn1
print *, (count + 1), "", fn
fn0 = fn1
fn1 = fn
end do loopfn
exit loop0
end do loop1
end do loop0
stop
end program Fibonacci
費式數列從WIKI上找到的是這樣
想問一下(loop0 : do)<===這用法是怎樣
有專業人士解說給小弟聽嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.91.81.203
推
01/01 23:25, , 1F
01/01 23:25, 1F
→
01/02 13:06, , 2F
01/02 13:06, 2F
推
01/03 14:44, , 3F
01/03 14:44, 3F
→
01/03 14:45, , 4F
01/03 14:45, 4F
Fortran 近期熱門文章
PTT數位生活區 即時熱門文章