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
Python Basic course of programming and algorithm Chapter 4 computer problems vue-cli Installation configuration in sassJAVA Implement simple section annotation pytorch torchvision.transforms.Normalize() In mean and std parameter --- Dispelling doubts 【Vue Easy to get started 】 Value transfer between parent and child components Oracle2021 Annual safety warning ,8 There are two security vulnerabilities that need attention C Language life game source code element-ui/vue-element-admin upload excel Wait for the file to go to the server The 11th Blue Bridge Cup b group pandas The best function in data processing apply+lambda