Advertisement
Oppaceted

Untitled

Mar 10th, 2023
1,049
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program hello
  2.     implicit none
  3.     !
  4.     integer :: i, l, k, n
  5.     real :: temp
  6.     real, allocatable :: array(:)
  7.     !
  8.     read (*,*) n
  9.     allocate(array(n))
  10.     do i = 1, n
  11.         write (*, *) 'Enter elem number:', i
  12.         read (*,*) array(i)
  13.     end do
  14.     write (*,*) 'Array:', array
  15.     do l = 1, (n - 1)
  16.         do k = 1, (n - l)
  17.             if ( array(k) > array(k+1) ) then
  18.                 temp =  array(k)
  19.                 array(k) = array(k+1)
  20.                 array(k+1) = temp
  21.             end if
  22.         end do
  23.     end do
  24.     write (*,*) 'Sorted array:', array
  25.     deallocate(array)
  26. end program
  27. ! Брайнарт
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement