题解 | #牛牛的金币#
牛牛的金币
http://www.nowcoder.com/practice/35d8e3e569dc49f2a1018d1dc9186998
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//牛牛的坐标
int x = scan.nextInt();
int y = scan.nextInt();
//金币的坐标
int x1 = scan.nextInt();
int y1 = scan.nextInt();
Coor coor = new Coor();
coor.c(x, y, x1, y1);
}
}
class Coor {
public void c(int x,int y,int x1,int y1) {
if(x == x1 && y1 - 1 == y) {
System.out.println("u");
} else if(x == x1 && y - 1 == y1) {
System.out.println("d");
} else if(x1 - 1 == x && y1 == y) {
System.out.println("r");
} else if(x - 1 == x1 && y1 == y) {
System.out.println("l");
}
}
}
Java基础练习题 文章被收录于专栏
都是一些基础的语法题目,每天可以刷几道。