Discuss / Java / 作业

作业

Topic source

//一元二次方程

public class Main {

public static void maid(String[] args) {

double a = 1.0;

double b = 3.0;

double c = -4.0;

//求平方根可用 Math.sqrt():

//System.out.println(Math.sqrt(2)); ==>1.414

//TODO

double r1 = 0;

double r2 = 0;

r1 = ((-b + Math.sqrt(b*b-4*a*c))/2*a);

r2 = ((-b - Math.sqrt(b*b-4*a*c))/2*a);

System.out.println(r1);

System.out.println(r2);

System.out.printlin(r1 == 1 && r2 == -4? "测试通过" : "测试失败”)‘

}

}

Gopid丶Pupil

#2 Created at ... [Delete] [Delete and Lock User]

那个我想问一下   double a =1.0   double b=3.0 double c=-4.0怎么来的 我后面会 这点不明白不清楚


  • 1

Reply