题解 | #迷路的牛牛#

迷路的牛牛

http://www.nowcoder.com/practice/fc72d3493d7e4be883e931d507352a4a

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()) {
            int N = sc.nextInt();
            char[] arr = sc.next().toCharArray();
            HashMap<String, String> map = new HashMap<>();
            map.put("NL", "W");
            map.put("EL", "N");
            map.put("SL", "E");
            map.put("WL", "S");
            map.put("NR", "E");
            map.put("ER", "S");
            map.put("SR", "W");
            map.put("WR", "N");
            String now = "N";
            for(int i = 0; i < N; i++) {
                now = map.get(now + arr[i]);
            }
            System.out.println(now);
        }
    }
}
全部评论

相关推荐

点赞 评论 收藏
分享
这不纯纯作弊了吗😢😢😢
编程界菜鸡:信这个的这辈子有了,这智商你靠啥都没用
点赞 评论 收藏
分享
06-26 15:33
青岛工学院 Java
积极的秋田犬要冲国企:他现在邀请我明天面试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务