题解 | #牛牛的金币#

牛牛的金币

https://www.nowcoder.com/practice/35d8e3e569dc49f2a1018d1dc9186998

public class Program {
    public static void Main() {
        //因为金币一定在周围,所以必然会有一个坐标相等,另外一个坐标相差1
        //x和x1相等的情况下,就比较y和y1,y大就说明向下,y1大就说明向上
        string line;
        string nums = "";
        while ((line = System.Console.ReadLine()) != null) {
            nums += line + " ";
        }

        string[] Number = nums.Split(" ");

        int x = int.Parse(Number[0]);
        int y = int.Parse(Number[1]);
        int x1 = int.Parse(Number[2]);
        int y1 = int.Parse(Number[3]);

        if (x == x1) {
            if (y > y1)
                System.Console.WriteLine("d");
            else
                System.Console.WriteLine("u");
        }

        else if (y == y1) {
            if (x > x1)
                System.Console.WriteLine("l");
            else
                System.Console.WriteLine("r");

        }

    }
}

全部评论

相关推荐

每晚夜里独自颤抖:你cet6就cet6,cet4就cet4,你写个cet证书等是什么意思。专业技能快赶上项目行数,你做的这2个项目哪里能提现你有这么多技能呢
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务