module quicksort_function implicit none contains recursive function qsort(x) result(quick) integer(4), allocatable :: quick(:) integer(4), intent(in) :: x(:) if (size(x) > 1) then quick = [qsort(pack(x(2:),x(2:)=x(1)))] else quick = x end if end function qsort end module quicksort_function program Sinki use quicksort_function implicit none integer(4) n,i,a integer(4),allocatable :: x(:) integer(4),allocatable :: y(:) read(*,*) n allocate (x(1:n)) allocate (y(1:n)) read(*,*) x(1:n) y=qsort(x) deallocate(x) do i=1,n if (y(i-1)/=y(i).and.y(i)/=y(i+1)) then a=a+1 end if end do write(*,*) a end program Sinki