SHARE
TWEET

Untitled

a guest Jun 24th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Scanner in = new Scanner(System.in);
  5.         String a = in.nextLine();
  6.         int x=0,y=0,num;
  7.  
  8.         String [] way = a.split(" ");
  9.         for(int i=0,j=1; i<way.length;i+=2,j+=2){
  10.             num = Integer.parseInt(way[j]);
  11.             switch (way[i]){
  12.                 case "North":y+=num;
  13.                 case "South":y-=num;
  14.                 case "East":x+=num;
  15.                 case "West":x-=num;
  16.  
  17.             }
  18.  
  19.         }
  20.         System.out.println(x+" "+y);
  21.     }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top