[Fortran] 纯文本查看 复制代码
program main
implicit none
integer r,k,m
integer n
logical :: pe(7,7) = reshape( ((/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0&
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0/)==1) , (/7,7/) )
logical :: lg(7,7) = reshape( ((/0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,1,0,1&
,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1/)==1) , (/7,7/) )
n=7
m=0
k=1
call sub1(k,n,m)
print *,m
contains
recursive subroutine sub1(k,n,m)
implicit none
integer n,k,i,r,q,m
if (lg(k,1).and.k<8) then
lg(k,1)=.false.
k=k+1
if(k==7)then
m=m+1
end if
call sub1(k,n,m)
end if
if (lg(k,2).and.k<8) then
lg(k,2)=.false.
k=k+1
if(k==7)then
m=m+1
end if
call sub1(k,n,m)
end if
if (lg(k,3).and.k<8) then
lg(k,3)=.false.
k=k+1
if(k==7)then
m=m+1
end if
call sub1(k,n,m)
end if
if (lg(k,4).and.k<8) then
lg(k,4)=.false.
k=k+1
if(k==7)then
m=m+1
end if
call sub1(k,n,m)
end if
if (lg(k,5).and.k<8) then
lg(k,5)=.false.
k=k+1
if(k==7)then
m=m+1
end if
call sub1(k,n,m)
end if
if (lg(k,6).and.k<8) then
lg(k,6)=.false.
k=k+1
if(k==7)then
m=m+1
end if
call sub1(k,n,m)
end if
if (lg(k,7).and.k<8) then
lg(k,7)=.false.
k=k+1
if(k==7)then
m=m+1
end if
call sub1(k,n,m)
end if
end subroutine
end program main