import java.util.Scanner;
import java.math.*;
public class Main {
static double f(double x) {
// double y;
if (x > 0 && x < 10)
return Math.log(x) / Math.log(2);
else if (x < 0)
return Math.abs(x) + Math.sin(x);
else if (x == 0)
return 0;
else
return x * x;
}
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
while (input.hasNext()) {
int t = input.nextInt();
int i;
double x;
for (i = 1; i <= t; i++) {
x = input.nextDouble();
System.out.printf("%.2f\n",f(x));
}
}
}
}
分段函数
最新推荐文章于 2018-09-28 17:07:15 发布