program main implicit none integer::N,hit,blow,i,j,k,l,blows integer::set(1:4) data hit/0/,blow/0/,blows/1/ do i=0,9 print '(4i1)',i,i,i,i read *,hit, blow if(hit+blow.ne.0) set(blows:blows+hit+blow-1)=i blows = blows + hit + blow if(hit.eq.4) return if(blows.gt.4) exit end do do i=1,4 do j=1,4 if(j.eq.i) cycle do k=1,4 if(k.eq.j.or.k.eq.i) cycle do l=1,4 if(l.eq.k.or.l.eq.j.or.l.eq.i) cycle print '(4i1)',set(i),set(j),set(k),set(l) read *,hit, blow if(hit.eq.4) return end do end do end do end do end program main