Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args)
- {
- double a, b, c, D;
- Scanner in = new Scanner(System.in);
- a = in.nextInt();
- b = in.nextInt();
- c = in.nextInt();
- D = b * b - 4*a*c;
- System.out.println(D);
- if (D > 0) {
- double x1, x2;
- x1 = (-b - Math.sqrt(D)) / (2 * a);
- x2 = (-b + Math.sqrt(D)) / (2 * a);
- System.out.println("x1 = " + x1 + ", x2 = " + x2);
- }
- else if (D == 0) {
- double x;
- x = -b / (2 * a);
- System.out.println("x = " + x);
- }
- else {
- System.out.println("Уравнение не имеет корней");
- }
- //я пытался
- }
- }
Add Comment
Please, Sign In to add comment