import java.util.Scanner;
public class Main {
public static int sign(int number) {
if(number > 0) {
int a = 1;
return a;
}
else if(number < 0) {
int a = -1;
return a;
}
else if(number == 0) {
int a = 0;
return a;
}
}
/* Do not change code below */
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
final int n = scanner.nextInt();
System.out.println(sign(n));
}
}
/*что делаю не так?
Write a method with the name sign that takes an int number and checks whether the number is negative, positive or zero. The method should return -1, +1 or 0 respectively.Jake
9 уровень
что делаю не так?
Решен
Комментарии (1)
- популярные
- новые
- старые
Для того, чтобы оставить комментарий Вы должны авторизоваться
JakeAndroid Developer в Яндекс
29 мая 2020, 14:50
int a = 0;
if(number > 0) {
a = 1;
} else if(number < 0) {
a = -1;
} else {
a = 0;
}
return a;
}
0