face where


Submit solution

Points: 50 (partial)
Time limit: 1.0s
Memory limit: 256M

Authors:
Problem type
Allowed languages
Java 19, Java 8

題目說明

請設計一程式,讓使用者可以輸入若干個CSRL(僅大寫字母)來控制機器人:

R代表朝向右

L向左

S不動(此時的下一個指令將不做出回饋,亦即跳過下一指令,如S R L,可視為僅有L)

C表示轉換方向 (此時的RL個分別為向左與向右,再輸入一次C則換回來)

輸入0表結束輸入,之後輸出此時面向的方位(預設朝向北方N,輸出以大寫字母表示)

輸入限制 此程式僅透過CSRL0做互動,第一位必不為0

方位:

   N
W     E
   S

測資0 輸入

R L L C L 0

測資0 輸出

N

解釋: R-> E , L-> N , L-> W , C-> (R=L, L=R) , L-> N

測資1 輸入

R L S L R S R 0

測資1 輸出

E

解釋: R -> E , L -> N , S -> - , L -> - , R -> E , S -> - , R -> -

測資2 輸入

S S C R R L 0

測資2 輸出

W

Comments


  • 0
    scu13156114  commented on Nov. 16, 2024, 10:03 p.m.

    Can the current instriction "S" got ignored when the previous effective instriction "S" is there? Can the current instriction "C" got ignored when the previous effective instriction "S" is there?