【发布时间】:2013-06-02 23:42:57
【问题描述】:
求解一个二次方程
到目前为止,我已经写下了以下内容。不知道怎么介绍第二种方法
public static void main(string args[]){
}
public static double quadraticEquationRoot1(int a, int b, int c) (){
}
if(Math.sqrt(Math.pow(b, 2) - 4*a*c) == 0)
{
return -b/(2*a);
} else {
int root1, root2;
root1 = (-b + Math.sqrt(Math.pow(b, 2) - 4*a*c)) / (2*a);
root2 = (-b - Math.sqrt(Math.pow(b, 2) - 4*a*c)) / (2*a);
return Math.max(root1, root2);
}
}
【问题讨论】:
-
为什么要返回根的最大值?为什么不是包含两个根的数组?
标签: java applet computer-science