program main
implicit none
integer,parameter :: M=2,N=3
integer :: b(2,3)=(/2,8,10,9,6,7/)
integer :: aa(2,3),c(3)
integer :: i,j,k,l,temp
do i=1,2
do j=1,3
write(*,*) i,j,b(i,j)
c(j)=b(i,j)
call BUBBLE_SORT(c,j)
aa(i,j)=c(j)
enddo
enddo
write(*,"(2(1xI2))") ((aa(i,j),i=1,2),j=1,3)
stop
end program main
subroutine BUBBLE_SORT(A,N)
implicit none
integer :: N,A(N)
integer I,J,K,TEMP
do I=N-1,1,-1
do J=1,I
if (A(J)>A(J+1))then
TEMP=A(J)
A(J)=A(J+1)
A(J+1)=TEMP
end if
enddo
enddo
return
end subroutine
输出的结果应该是
2 7
6 8
10 9
实际输出的结果是
2 8
10 9
10 9
慕莱坞森
相关分类