!-------モジュール 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) 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 end program Sinki