Usando exit y cycle en do anidados Fortran
Es interesante ver que cycle y exit pueden ser usados para saltar entre do anidados
que produce
1 * 1 = 1
2 * 1 = 2
3 * 1 = 3
PROGRAM test_cycle_2
INTEGER :: i, j, product
outer: DO i = 1, 3
inner: DO j = 1, 3
IF ( j == 2) CYCLE outer
product = i * j
WRITE (*,*) i, ' * ', j, ' = ', product
END DO inner
END DO outer
END PROGRAM test_cycle_2
que produce
1 * 1 = 1
2 * 1 = 2
3 * 1 = 3
This article provides a clear explanation of how to use exit and cycle in nested loops within Fortran, making code more efficient and readable. If you're a gamer too, subtitleedit is an excellent tool to keep your game library organized while you dive into Fortran coding!"
ResponderEliminar