一碗罗狮粉


私信TA

用户名:uq_89718803495

访问量:174

签 名:

等  级
排  名 7412
经  验 1265
参赛次数 0
文章发表 7
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

import java.util.Scanner;


public class Main {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

    int a,b,c;

    double x1,x2,t;

    a=in.nextInt();

    b=in.nextInt();

    c=in.nextInt();

    t=Math.pow(b,2)-4*a*c;

    if(t>0){

        x1=(-b+Math.sqrt(t))/2*a;

        x2=(-b-Math.sqrt(t))/2*a;

        System.out.println("x1="+x1+" "+"x2="+x2);

    }

    else if(t==0){

        x1=(-b+Math.sqrt(t))/2*a;

        x2=(-b-Math.sqrt(t))/2*a;

        System.out.println("x1="+x1+" "+"x2="+x2);

    }

    else if(t<0){

       double n=-b*1.0/(2*a);

        double m=Math.sqrt(-t)/(2*a);

        System.out.printf("x1=%.3f+%.3fi x2=%.3f-%.3fi",n,m,n,m);

    }

}

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区