李伟嘉


私信TA

用户名:uq_84409864200

访问量:887

签 名:

等  级
排  名 2749
经  验 2075
参赛次数 38
文章发表 6
年  龄 19
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

简单的数学题
浏览:119
DNA-一种题解
浏览:80

参考代码:

public void distance1() {
    Scanner sc = new Scanner(System.in);
    while (sc.hasNext()) {
        int x = sc.nextInt();
        int y = sc.nextInt();
        double res = Math.abs(3*x-y+4)*1.0/Math.sqrt(3*3+1);
        System.out.printf("%.6f\n",res);
        //打印也可以写成这样System.out.println(String.format("%.6f", d));
    }
}

public void distance2() {
    /*
     * 静态导入:Java5的新特性,导入的是类里面的静态成员
     *   import static java.lang.Math类:具体参见API
     */
    Scanner sc = new Scanner(System.in);
    while (sc.hasNext()) {
        int x = sc.nextInt();
        int y = sc.nextInt();
        double res = abs(3*x-y+4)*1.0/sqrt(3*3+1);
        System.out.printf("%.6f\n",res);
        //打印也可以写成这样System.out.println(String.format("%.6f", d));
    }
}


 

0.0分

0 人评分

  评论区