作者chinhan1216 (下巴翰)
看板Fortran
标题[问题] loop的用法
时间Sat Jan 1 22:51:33 2011
小弟这学期刚学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
1F:推 hillock0:替回圈取名loop0 01/01 23:25
2F:→ latinboy: 为何wiki写的这麽复杂.... 01/02 13:06
3F:推 shrekwang:当初 wiki 费氏数列的Fortran程式是我写的 但是不知道是 01/03 14:44
4F:→ shrekwang:谁改成这样...... 01/03 14:45