!-------モジュール module quicksort_function implicit none contains !再帰型副関数 recursive function qsort(x) result(quick) integer(4), allocatable :: quick(:) integer(4), intent(in) :: x(:) integer(4) mid mid=(size(x)/2) if (size(x) > 1) then quick = [qsort(pack(x,xx(mid)))] else quick = x end if end function qsort end module quicksort_function !------主プログラム program Sort use quicksort_function implicit none integer(4) m,n,i,a integer(4),allocatable :: x(:) integer(4),allocatable :: y(:) read(*,*) n allocate (x(1:n)) allocate (y(1:n)) read(*,*) (x(m),m=1,n) y=qsort(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 write(*,*) y end program Sort