实验2-2-1 计算分段函数[1]

package com.company;

import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception{
    // write your code here
        Scanner sc=new Scanner(System.in);
        double x=sc.nextDouble();
        double result;
        DecimalFormat df=new DecimalFormat("0.0");
        if(x!=0){
            result=1/x;
        }else{
            result=0;
        }
        System.out.println("f("+df.format(x).toString()+")="+df.format(result).toString());
    }
}

感觉有点费劲了,这才到哪?

猜你喜欢

转载自www.cnblogs.com/zhuzehua/p/9670540.html