Fortran-停止語句



如果您希望程式執行停止,您可以插入一個停止語句。

示例

program stop_example     
implicit none

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

編譯並執行上述程式碼後,會生成以下結果 −

1
2
3
4
fortran_loops.htm
廣告
© . All rights reserved.