另一个小数点

 1 import java.util.Scanner;
2 public class Test30009{
3 public static void main(String args[]){
4 int repeat, ri;
5 int a,b,c,d;
6 double x1,x2;
7 Scanner in=new Scanner(System.in);
8 repeat=in.nextInt();
9 for(ri = 1; ri <= repeat; ri++){
10 a=in.nextInt();b=in.nextInt();c=in.nextInt();
11 /*---------*/
12 d=b*b-4*a*c;
13 if(a==0&&b==0&&c==0){
14 System.out.println("a=b=c=0,meaningless");
15 }else if(a==0&&b==0&&c!=0){
16 System.out.println("a=b=0,c!=0,error");
17 }else if(a==0&&b!=0&&c!=0){
18 System.out.println("x="+(double)Math.round((double)(-c)/b*100)/100);
19 }else if(d>=0){
20 System.out.println("x1="+(double)Math.round(((-b)+Math.sqrt(d))/(2*a)*100)/100);
21 System.out.println("x2="+(double)Math.round(((-b)-Math.sqrt(d))/(2*a)*100)/100);
22 }else if(d<0){
23 System.out.println("x1="+(double)(-b)/(2*a)+"+"+(double)Math.round((Math.sqrt(-d)/(2*a))*100)/100+"i");
24 System.out.println("x2="+(double)(-b)/(2*a)+"-"+(double)Math.round((Math.sqrt(-d)/(2*a))*100)/100+"i");
25 }
26 }
27 }
28 }
posted on 2012-03-22 23:27  clara_babybear  阅读(249)  评论(0编辑  收藏  举报