fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. double a,b,c,d,D;
  10. double x1,x2,x3;
  11. Scanner in = new Scanner(System.in);
  12. while (in.hasNextDouble()){
  13. a = in.nextDouble();
  14. b = in.nextDouble();
  15. c = in.nextDouble();
  16. d = in.nextDouble();
  17. D=b*b-4*a*(c-d);
  18. if(D>0){
  19. x1=(-b-Math.sqrt(D))/(2*a);
  20. x2=(-b+Math.sqrt(D))/(2*a);
  21. System.out.println(x1+" "+x2+";");
  22. }
  23. else{
  24. if(D==0){
  25. x3=(-b)/(2*a);
  26. System.out.println(x3+";");
  27. }
  28. else System.out.println("нет корней;");
  29. }
  30. }
  31. }
  32. }
  33.  
Success #stdin #stdout 0.14s 31260KB
stdin
1 1 -6 -2 1 -2 10 0
stdout
-2.5615528128088303 1.5615528128088303;
нет корней;