<span style="font-size:24px;">package NiukeBrush; //开发一个坐标计算工具, A表示向左移动,D表示向右移动,W表示向上移动, //S表示向下移动。从(0,0)点开始移动 //,从输入字符串里面读取一些坐标,并将最终输入结果输出到输出文件里面。 import java.util.Scanner; public class Huawei17 { public static void main(String[] args) { // { // String st=sc.nextLine(); // String[] str=st.split(";"); // int n=sc.nextInt(); // StringBuilder sb=new StringBuilder(st); // //统计A,B,C,D变量 // int a=0; // int a1=0; // int b=0; // int b1=0; // int c=0; // int c1=0; // int d=0; // int d1=0; // // //当sb.length的长度等于1的时候 // for(int i=0;i<str.length;i++) // { // while(str[i].length()==3){ // // 如果字符索引的第一个等于A、B、C、D // if((st.charAt(0)=='A')) // { // a++; // // } // else if(st.charAt(0)=='B') // { // b++; // } // else if(st.charAt(0)=='C') // { // c++; // } // else if(st.charAt(0)=='D') // { // d++; // } // //键盘输入 Scanner sc=new Scanner(System.in); //定义横坐标、纵坐标 int x=0; int y=0; String st=sc.nextLine(); String[] str=st.split(";"); while(sc.hasNext()){ //遍历循环 for(int i=0;i<str.length;i++) { //判断这个字符串的长度,不能大于三位 while(str[i].length()<=3) { if(str[i].charAt(0)=='A'&& str[i].substring(1).matches("[0-9]+")) { x-=Integer.parseInt(str[i].substring(1)); } if(str[i].charAt(0)=='D'&& str[i].substring(1).matches("[0-9]+")) { x+=Integer.parseInt(str[i].substring(1)); } if(str[i].charAt(0)=='W'&& str[i].substring(1).matches("[0-9]+")) { y+=Integer.parseInt(str[i].substring(1)); } if(str[i].charAt(0)=='S'&& str[i].substring(1).matches("[0-9]+")) { y-=Integer.parseInt(str[i].substring(1)); } } } } sc.close(); System.out.println("("+x+","+y+"0"); } } </span>