看板 Fortran 關於我們 聯絡資訊
小弟這學期剛學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
hillock0:替迴圈取名loop0 01/01 23:25
latinboy: 為何wiki寫的這麼複雜.... 01/02 13:06
shrekwang:當初 wiki 費氏數列的Fortran程式是我寫的 但是不知道是 01/03 14:44
shrekwang:誰改成這樣...... 01/03 14:45