|  | 
 
| module qsort_c_module implicit none
 public :: QsortC
 private :: Partition
 contains
 recursive subroutine QsortC(A,B)
 real, intent(in out), dimension(:) :: A
 real, intent(in out), dimension(:,:) :: B
 integer :: iq
 if(size(A) > 1) then
 call Partition(A, iq, B)
 call QsortC(A(:iq-1),B(:,:iq-1))
 call QsortC(A(iq:),B(:,iq:))
 endif
 end subroutine QsortC
 subroutine Partition(A, marker, B)
 real, intent(in out), dimension(:) :: A
 real, intent(in out), dimension(:,:) :: B
 integer, intent(out) :: marker
 integer :: i, j
 real :: temp
 real ,dimension(1:size(A))::temb
 real :: x      ! pivot poin
 x = A(1)
 i= 0
 j= size(A) + 1
 do
 j = j-1
 do
 if (A(j) <= x) exit
 j = j-1
 end do
 i = i+1
 do
 if (A(i) >= x) exit
 i = i+1
 end do
 if (i < j) then
 ! exchange A(i) and A(j)
 temp = A(i)
 temb = B(:,i)
 A(i) = A(j)
 B(:,i)=B(:,j)
 A(j) = temp
 B(:,j)=temb
 elseif (i == j) then
 marker = i+1
 return
 else
 marker = i
 return
 endif
 end do
 end subroutine Partition
 end module qsort_c_module
 program www_fcode_cn
 use qsort_c_module
 implicit none
 integer, parameter :: r = 3
 real, dimension(1:r) :: myarray = (/0, 50, 20/)
 real, dimension(1:r,1:r) :: mb=(/1,2,3,4,5,6,7,8,9/)
 write(2,*) "原数组:", myarray
 write(2,'*') "原数组:", mb
 call QsortC(myarray,mb)
 write(2,*) "排序后:", myarray
 write(2,'*') "排序后:", mb
 end program www_fcode_cn
 
 用这个修改后的快速排序法,排列特征值A,和特征向量B,出现了错误:
 B排序输出后,出现了这样的数字:1.000000       2.000000       3.000000       7.000000
 8.000000       9.000000       4.000000       5.000000     -1.5823616E-26
 请问是哪里出错了,非常感谢
 
 | 
 |