Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer, allocatable :: A(:), Positives(:)
- logical, allocatable :: Pos(:)
- open (file=input_file, newunit=In)
- read (In, *) M
- allocate (A(M))
- read (In, *) A
- close (In)
- open (file=output_file, encoding=E_, newunit=Out)
- write (Out, "("//M//"f6.2)") A
- close (Out)
- allocate(Pos(M))
- write (*,*) Sort(A)
- open (file=output_file, encoding=E_, newunit=Out, position='append')
- write (Out, "(/"//M//"f6.2)") A
- close (Out)
- contains
- pure function Sort(A) result(Z)
- integer len, i, j, tmp
- integer, allocatable :: Z(:)
- integer, intent(in) :: A(:)
- Z = A
- len = Size(Z)
- do i = 1, len
- do j = 1, len - i
- if (Z(j) > Z(j+1)) then
- tmp = Z(j+1)
- Z(j+1) = Z(j)
- Z(j) = tmp
- end if
- end do
- end do
- end function Sort
- end program lab_7_2a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement