题解 | #计算y的值#
计算y的值
http://www.nowcoder.com/practice/61a0f16117484d219b59c62224b33b1c
三目运算符判断
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int x = in.nextInt();
int y = (x > 0)? -1 : (x == 0) ? 0 : 1;
System.out.println(y);
}
}