0
Why this code doesn’t print value ,,0”?
As in topic: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); int number = read.nextInt(); //your code goes here for (int x=number; x>=0; x--){ if (x%3==0){ continue; }System.out.println(x); } } }
4 ответов
+ 3
Just make sure x isn't equal to 0 in your if condition.
if (x%3 == 0 && x != 0) {
continue;
}
+ 2
Damn now thats looks soo eazy. I forgot about this solution. Thx so much ;)
+ 1
Because 0%3 == 0 is true so the continue statement is ran and the loop moves on to the next iteration where x is reduced to -1 and the loop exits.
+ 1
Hm I understand now but how to solve it rn?