관리 메뉴

드럼치는 프로그래머

[M2S] 2009년 01월 16일 금요일 C언어 DailyQuiz 04 ( Bananas ) 본문

★─M2S Study/☆─09.01 Daily

[M2S] 2009년 01월 16일 금요일 C언어 DailyQuiz 04 ( Bananas )

드럼치는한동이 2009. 1. 14. 21:25
Problem : Bananas

The term “code monkey” is sometimes used to refer to a programmer who doesn't know much about programming. This is unfair to monkeys, because contrary to popular belief, monkeys are quite smart. They have just been misunderstood. This may be because monkeys do not speak English, but only monkey language. Your job is to help humans and monkeys understand each other by writing a monkey language dictionary. For each word that is typed in, your program must determine whether it is a valid monkey language word.

Unlike in English, spelling in monkey language is very simple. Every word in monkey language satisfies the following rules, and every word satisfying the following rules is a monkey language word.

1. A monkey language word is a special type of word called an A-word, which may be optionally followed by the letter N and a monkey language word.

2. An A-word is either only the single letter A, or the letter B followed by a monkey language word followed by the letter S.

Here are some examples:

The word “A”' is a monkey language word because it is an A-word.

The word “ANA” is a monkey language word because it is the A-word “A” followed by the letter N and the monkey language word “A”.

The word “ANANA” is a monkey language word because it is the A-word “A” followed by the letter N and the monkey language word “ANA”.

The word “BANANAS” is a monkey language word because it is an A-word, since it is the letter B followed by the monkey language word “ANANA” followed by the letter S.

Write a program which accepts words, one word on each line, and for each word prints YES if the word is a monkey language word, and NO if the word is not a monkey language word. The input word “X” indicates the program should terminate, and there is no output for word “X” (even though it is not a monkey word).

Sample Input
A
NA
ANANA
BANANAS
BANANA
X

Sample Output for Sample Input
YES
YES
YES
YES
NO


ps. 원서에서 발취한 내용이니 알아서 해석해서 풀도록!



기한 : 2009년 1월 19일 월요일 PM 12:00 ( 정오 ) 까지.

제출 : rockdrumy@nate.com or 네이트온.

제출방법 : 워드문서로 레포트 형식과 동일하게 소스와 실행화면 스샷과 함께 작성하고, 
               Word 파일과 c 파일 1개로 압축하여 제출. 

궁금한 점은 무조건 저한테만 문의 바람. 웹사이트 & 네이버 지식검색 참조 금물.
Comments