HWOJ坐标移动

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int n0 = 0;
        for(int p=0;p1){
                num = r.substring(1);
                for(int j=0;j='0')){
                        b = false;
                        break;
                    }else{
                        b = true;
                    }
                }
            }else{
                b = false;
            }
            if(r.length()>1){
                c = true;
            }
            
            if(b&&c){
                count = Integer.parseInt(num);
                n[0]+=get(r.charAt(0),count)[0];
                n[1]+=get(r.charAt(0),count)[1];
            }
        }
        sc.close();
        System.out.println(n[0]+","+n[1]);
    }
    public static int[] get(char c,int n5) {
        int[] n7 = new int[2];
            if(c=='A'){
                n7[0] -= n5;
            }
            if(c=='S'){
                n7[1] -= n5;
            }
            if(c=='W'){
                n7[1] += n5;
            }
            if(c=='D'){
                n7[0] += n5;
            }
        return n7;
    }
}

你可能感兴趣的:(HWOJ坐标移动)