参考代码:
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 人评分
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:630 |
川哥的吩咐 (C++代码)浏览:1007 |
C语言训练-素数问题 (C语言代码)浏览:990 |
C语言训练-大、小写问题 (C语言代码)浏览:611 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:609 |
字符逆序 (C语言代码)浏览:455 |
A+B for Input-Output Practice (C语言代码)浏览:458 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:1067 |
Tom数 (C语言代码)浏览:492 |
【计算直线的交点数】 (C语言代码)浏览:916 |