Piecewise function evaluation
Time Limit: 1000 ms Memory Limit: 65536 KiB
Submit Statistic
Problem Description

There are the following piecewise functions
F(x) = x^2 + 1 When x> 0 Time ;
F(x) = -x When x<0 Time ;
F(x) = 100.0 When x=0 Time ;
Programming depends on the input x(x Is a real number ), Output its corresponding function value
Input

Multi group input , Each group has one real number x. Process to the end of the file .
Output

For each group of inputs x, Output its corresponding F(x), One line per group , Results reserved 1 Decimal place .
Sample Input

8.00
-5.0
Sample Output

65.0
5.0
Hint
import java.text.DecimalFormat; import java.util.Scanner; public class Main {
public static void main(String[] args) { Scanner str = new Scanner(System.in);
DecimalFormat df =new DecimalFormat("0.0"); double x, y; while(str.hasNext()) {
x = str.nextDouble();if(x > 0) { y = x * x + 1; } else if(x < 0) { y = - x; }
else y = 100.0; System.out.println(df.format(y)); } str.close(); } }

Technology
©2020 ioDraw All rights reserved
LeetCode quick get start ① —— Array series ( Often asked in an interview , Suggested collection ) Apple iPhone 12 Price leakage : The official highest price is close to 1 Ten thousand yuan ( Essence )2020 year 6 month 26 day C# Class library Ip Address help class spark.sql.shuffle.partitions and spark.default.parallelism The difference between flutter study -- Search box NVIDIA official apology : Robots are sold out RTX 3080django Do not close CSRF middleware , Custom through CSRF Tested post request 【 Deep learning 】 Target detection in progress IOU The concept and calculation of ( Essence )2020 year 6 month 26 day C# Class library DataTable( Extension method ) Can Huawei Hongmeng system and Android , Apples compete against each other ?