Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- String a = in.nextLine();
- int x=0,y=0,num;
- String [] way = a.split(" ");
- for(int i=0,j=1; i<way.length;i+=2,j+=2){
- num = Integer.parseInt(way[j]);
- switch (way[i]){
- case "North":y+=num;
- case "South":y-=num;
- case "East":x+=num;
- case "West":x-=num;
- }
- }
- System.out.println(x+" "+y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement