public class 求一元二次方程的解 {
public static void main(String[] args) {
double a = 1.0;
double b = 3.0;
double c = -4.0;
double d = Math.pow(b, 2) - 4 * a * c;
double e = (-b + Math.pow(d, 0.5))/2*a;
double f = (-b - Math.pow(d, 0.5))/2*a;
System.out.println(e);
System.out.println(f);
}
Sign in to make a reply
对酒当歌
public class 求一元二次方程的解 {
public static void main(String[] args) {
double a = 1.0;
double b = 3.0;
double c = -4.0;
double d = Math.pow(b, 2) - 4 * a * c;
double e = (-b + Math.pow(d, 0.5))/2*a;
double f = (-b - Math.pow(d, 0.5))/2*a;
System.out.println(e);
System.out.println(f);
}
}