标签:
package exercise3; import java.util.Scanner; public class Main1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); double a = input.nextDouble(); double b = input.nextDouble(); double c = input.nextDouble(); double panbieshi = b*b-4*a*c; if(panbieshi < 0) { System.out.println("没有值"); } else if(panbieshi == 0) { double r1 = -b/(2*a); System.out.println(r1); }else{ double r1 = (-b + Math.pow(panbieshi, 0.5)) / (2 * a); double r2 = (-b - Math.pow(panbieshi, 0.5)) / (2 * a); System.out.println("The roots are " + r1 + " and " + r2); } } }
标签:
原文地址:http://www.cnblogs.com/aicpcode/p/4396309.html