program abby
implicit none
character(1),dimension(4),parameter :: ans=(/'0','2','1','4'/)
character(1),dimension(4) :: try
integer(4) :: i,j,a=0,b=0,n=0
n=0
DO WHILE(a/=4)
n=n+1
read(*,'(4a1)') try
a=0
do i=1,4
if(try(i)==ans(i)) then
a=a+1
try(i)='x'
endif
enddo
b=0
do i=1,4
do j=1,4
if(try(i)==ans(j)) b=b+1
enddo
enddo
print*,n,':',a,'A',b,'B'
ENDDO
end program abby
※ 引述《key000079 (key000079)》之铭言:
: 有人会几A几B 数字游戏fortran 95的写法吗? 大家都是c++可是我想知道fortran写法?
: 期末考试考题求大家帮帮忙