fork(1) 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)
  8. {
  9. double a, b, c, d, D;
  10. double x1,x2,x3;
  11. Scanner s =new Scanner(System.in);
  12. while(s.hasNext()){
  13. a= s.nextInt();
  14. b= s.nextInt();
  15. c= s.nextInt();
  16. d= s.nextInt();
  17. D=b*b-4*a*(c-d);
  18. if(D>0)
  19. {
  20. x1=(-b-Math.sqrt(D))/(2*a);
  21. x2=(-b+Math.sqrt(D))/(2*a);
  22. System.out.println(x1+", "+x2+"; ");
  23. }
  24. else if(D==0)
  25. {
  26. x3=(-b)/(2*a);
  27. System.out.println(x3+"; ");
  28. }
  29. else System.out.println("no roots"+"; ");
  30. }
  31. }
  32. }
Success #stdin #stdout 0.06s 4386816KB
stdin
1 3 -4 -1 2 -7 11 0
stdout
-3.79128784747792, 0.7912878474779199; 
no roots;