Fortran - 迴圈語句



cycle 語句會使迴圈跳過其正文的其餘部分,並在迭代之前立即重新測試其條件。

流程圖

Cycle Statement

示例

program cycle_example     
implicit none      

   integer :: i     
   
   do i = 1, 20          
   
      if (i == 5) then 
         cycle          
      end if         
      
   print*, i      
   end do  
   
end program cycle_example

當編譯並執行以上程式碼時,會產生以下結果 −

1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fortran_loops.htm
廣告
© . All rights reserved.