subroutine correct() print '("CORRECT (maybe)")' end subroutine correct subroutine wrong() print '("WRONG!")' end subroutine wrong function is_kigou(c) result(l) character::c integer::cnum logical::l cnum=ICHAR(c) l = .not.(((ICHAR('0')<=cnum).and.(cnum<=ICHAR('9'))).or. & ((ICHAR('a')<=cnum).and.(cnum<=ICHAR('z')))) end function is_kigou program main implicit none interface subroutine wrong() end subroutine wrong subroutine correct() end subroutine correct end interface integer::N,len,i logical::l character*100000::S do read (*,'(1000a)') S if(S =="") exit len=LEN_TRIM(S) if(len.le.5) then call wrong() cycle end if call lowering(S) if(S(1:4)=="digi") then l = search(S, "nyo") else if(S(1:5)=="petit") then l = search(S,"nyu") else if(S(1:4)=="rabi") then l = rabi(S) else if(S(1:4)=="gema") then l = search(S,"gema") else if(S(1:4)=="piyo") then l = search(S,"pyo") end if if(l.eqv..true.) then call correct() else call wrong() end if end do contains subroutine lowering(S) character*100000::S integer::snum do i=1,len snum=ICHAR(S(i:i)) if((65<=snum).and.(snum<=90)) S(i:i)=ACHAR(snum+32) end do end subroutine lowering function search(S,pattern) result(l) interface function is_kigou(c) result(l) character::c logical::l end function is_kigou end interface integer::i logical::l character*100000::S character*3,intent(in)::pattern l = .false. do i=0,3 if(S(len-2-i:len-i)==pattern) then l = .true. return end if if(.not.(is_kigou(S(len-i:len-i)))) then exit end if end do end function search function rabi(S) result(l) interface function is_kigou(c) result(l) character::c logical::l end function is_kigou end interface integer::i logical::l character*100000::S l = .false. do i=5,len if(.not.(is_kigou(S(i:i)))) then l = .true. return end if end do end function rabi end program main