Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program lab_7_2a
- use Environment
- implicit none
- character(*), parameter :: input_file = "../data/input.txt", output_file = "output.txt"
- integer :: In = 0, Out = 0, M = 0
- real(R_), 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 (*,*) SortBlyad(A)
- open (file=output_file, encoding=E_, newunit=Out, position='append')
- write (Out, "(/"//M//"f6.2)") A
- close (Out)
- contains
- subroutine SortBlyad(A)
- integer, intent(inout) :: A(:)
- integer :: len
- integer :: i, j, tmp
- len = Size(A)
- do i = 1, len
- do j = 1, len - i
- if (A(j) > A(j+1)) then
- tmp = A(j+1)
- A(j+1) = A(j)
- A(j) = tmp
- end if
- end do
- end do
- end subroutine
- end program lab_7_2a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement