Fare丶梦


私信TA

用户名:126913199

访问量:31022

签 名:

等  级
排  名 131
经  验 4890
参赛次数 0
文章发表 50
年  龄 22
在职情况 学生
学  校
专  业

  自我简介:

解题思路:





注意事项:


未使用枚举类型


参考代码:

import java.util.Scanner;


public class Main {

        public static void main(String[] arg){

                int num = 0;

                @SuppressWarnings("resource")

                Scanner sc = new Scanner(System.in);

                int N = sc.nextInt();

                int M = sc.nextInt();

                if(Math.abs(N-M)<=1){

                        if(N!=M){

                                num = (N>M)?N:M;

                                if(num==N)

                                        num=1;

                                else

                                        num=-1;

                        }

                        else

                                num=0;

                }

                else{

                        num = (N>M)?M:N;

                        if(num==M)

                                num=-1;

                        else

                                num=1;

                    }

                System.out.print(num);

        }

}


 

0.0分

2 人评分

  评论区