import java.util.Scanner; public class Main { 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 discriminant = b * b - 4 * a * c; if (discriminant > 0) { double x1 = (-b + Math.sqrt(discriminant)) / (2 * a); double x2 = (-b - Math.sqrt(discriminant)) / (2 * a); System.out.printf("x1=%.3f x2=%.3f%n", x1, x2); } else if (discriminant == 0) { double x1 = -b / (2 * a); System.out.printf("x1=%.3f%n", x1); } else { double realPart = -b / (2 * a); double imaginaryPart = Math.sqrt(-discriminant) / (2 * a); System.out.printf("x1=%.3f+%.3fi x2=%.3f-%.3fi%n", realPart, imaginaryPart, realPart, imaginaryPart); } } }
0.0分
0 人评分
妹子杀手的故事 (C语言代码)浏览:737 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:643 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:639 |
成绩转换 (C语言代码)浏览:1048 |
C语言训练-计算t=1+1/2+1/3+...+1/n (C语言代码)浏览:942 |
WU-小九九 (C++代码)浏览:1713 |
程序员的表白 (C语言代码)浏览:678 |
Quadratic Equation (C语言代码)浏览:1034 |
字符逆序 (C语言代码)浏览:541 |
上车人数 (C语言代码)浏览:753 |