?? dimidiate.java
字號:
package common;
public class Dimidiate {
/**
* @param args
*/
private double function(double x) {
// double result = Math.pow(x, 3) - 2 * Math.pow(x, 2) - 4 * x - 7;
double result = Math.pow(x, 3) - x- 1;
return result;
}
private void method(double a, double b, double s) {
double tempE = Math.abs((b - a) / 2);
System.out.print(a + " " + b + " ");
double tempM = (a + b) / 2;
System.out.print(tempM);
double value = function(tempM);
System.out.println(" " + value);
if (tempE <= s) {
// System.out.println(tempM);
return;
}
if (value == 0) {
// System.out.println(tempM);
return;
} else if (value > 0) {
method(a, tempM, s);
} else {
method(tempM, b, s);
}
}
public static void main(String[] args) {
// TODO 自動生成方法存根
new Dimidiate().method(1, 2, 0.001);
// new Dimidiate().method(3,4,0.005);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -