Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program swapper
- implicit none
- .
- .
- .
- interface swap
- procedure swap_int, swap_real, swap_char, swap_int_real
- end interface swap
- .
- .
- .
- call swap(a,b)
- pause
- contains
- elemental subroutine swap_int(a,b) !elemental позволяет использовать
- integer,intent(inout)::a,b !процедуру со скалярами и массивами
- integer::temp
- temp=a
- a=b
- b=temp
- end subroutine swap_int
- elemental subroutine swap_real(a,b)
- real,intent(inout)::a,b
- real::temp
- temp=a
- a=b
- b=temp
- end subroutine swap_real
- elemental subroutine swap_char(a,b)
- character(len=*),intent(inout)::a,b
- character(len=len(a))::temp
- temp=a
- a=b
- b=temp
- end subroutine swap_char
- elemental subroutine swap_int_real(a,b)
- integer,intent(inout)::a
- integer::temp
- real,intent(inout)::b
- temp=real(a)
- a=int(b)
- b=temp
- end subroutine swap_int_real
- end program swapper
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement