package practice;
import java.util.Scanner;
//题目描述
//牛牛去犇犇老师家补课,出门的时候面向北方,但是现在他迷路了。虽然他手里有一张地图,
//但是他需要知道自己面向哪个方向,请你帮帮他。
//输入描述:
//每个输入包含一个测试用例。
//每个测试用例的第一行包含一个正整数,表示转方向的次数N(N<=1000)。
//接下来的一行包含一个长度为N的字符串,由L和R组成,L表示向左转,R表示向右转。
//输出描述:
//输出牛牛最后面向的方向,N表示北,S表示南,E表示东,W表示西。
//示例1
//输入
//3
//LRR
//输出
//E
public class Direction {
public static void main(String args[]){
Scanner input=new Scanner(System.in);
int l=0,r=0;
char[] ansl={'N','W','S','E'};
char[] ansr={'N','E','S','W'};
int count=input.nextInt();
if(count<=1000){
String direction=input.next();
for(int i=0;i<count;i++){
if(direction.charAt(i)=='L'){
l++;
}else{
r++;
}
}
if((l-r)>=0){
System.out.println(ansl[(l-r)%4]);
}
else {
System.out.println(ansr[(r-l)%4]);
}
}
}
}
牛客网-迷路的牛牛
猜你喜欢
转载自www.cnblogs.com/lihuidong/p/11394665.html
今日推荐
周排行