一般在牛客上做题的时候是不需要关闭的,而在本地IDEA上则是需要关闭的
关闭方法`
while(!sc.hasNext("@")){
String s = sc.nextLine();
for(int i =0;i<s.length();i++){
if(s.charAt(i) == 'L'){
x--;
}else if(s.charAt(i) == 'R'){
x++;
}else if(s.charAt(i) == 'U'){
y++;
}else if(s.charAt(i) == 'D'){
y--;
}
}
}
可以看到
输出