Fortran-cycle

提供:Dev Guides
2020年6月23日 (火) 09:05時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

Fortran-サイクルステートメント

サイクルステートメントにより、ループは本体の残りをスキップし、反復する前にその状態をすぐに再テストします。

流れ図

サイクルステートメント

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