-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest12.java
57 lines (48 loc) · 881 Bytes
/
Test12.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.util.Scanner;
public class Test12 {
final static char ch[]={'N','E','S','W'};
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int p=0;
while(1==1){
String dir=sc.next();
int dis=sc.nextInt();
p=direction(dir,p+dis);
System.out.println("p---"+p);
System.out.println(ch[p]);
}
}
private static int direction(String dir, int dis) {
int pos=0;
if(dir.equalsIgnoreCase("C"))
{
if(dis>4){
dis=(dis%4);
pos=pos+dis;
}
else if(dis<4)
{
pos=pos+dis;
}
else
pos=0;
return pos;
}
else if(dir.equalsIgnoreCase("AC"))
{
System.out.println("dis---"+dis);
if(dis>4){
dis=dis%4-1;
pos=pos+ch.length-dis;
}
else if(dis<4)
{
pos=ch.length-dis;
}
else
pos=0;
return pos;
}
return 0;
}
}