Код: Выделить всё
//java
public class Fizzbuzz {
public static void main(String[] args) {
for(int i = 0; i < 100; i++ ) {
if(i % 5 == 0 && i % 7 == 0) {
System.out.println("FizzBuzz");
} else if(i % 5 == 0) {
System.out.println("Fizz");
} else if(i % 7 == 0) {
System.out.println("Buzz");
} else {
System.out.println(i);
}
}
}
}
Код: Выделить всё
//java
public class Fizzbuzz2 {
public static void main(String[] args) {
for(int i = 0; i < 100; i++ ) {
if(i % 5 == 0) {
System.out.print("Fizz");
}
if(i % 7 == 0) {
System.out.print("Buzz");
}
if(i % 5 != 0 && i % 7 != 0) {
System.out.print(i);
}
System.out.print(\n);
}
}
}
Код: Выделить всё
if (x), print fizz Код: Выделить всё
if (y), print buzzКод: Выделить всё
if neither of the first two, print i Кто-нибудь знает, как это сделать (на любом языке ?).
Подробнее здесь: https://stackoverflow.com/questions/793 ... -3rd-thing
Мобильная версия