题解 | #牛牛的金币#
牛牛的金币
https://www.nowcoder.com/practice/35d8e3e569dc49f2a1018d1dc9186998
//条件:坐标为整数,且保证 ∣x1−x∣+∣y1−y∣=1 //即x y 只有一个不同,且相差为1 import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); int x1 = sc.nextInt(); int y1 = sc.nextInt(); if(x < x1){ System.out.print("r"); }else if(x > x1){ System.out.print("l"); }else if(y < y1){ System.out.print("u"); }else{ System.out.print("d"); } } }