Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement