8/11 postscript ・ 3/0 is an error (ArithmeticException), but 0/3 is not an error
Basic rule: Multiples of 3 have "!!"
Nabeatsu.java
import java.util.Random;
import java.util.Scanner;
public class Nabeatsu {
public static void main(String[] args) {
//Be stupid by multiples of 3
Scanner scan = new Scanner(System.in);
int number = scan.nextInt();
for(int i = 1;i <= number; i++) {
if(i % 3 == 0)
System.out.println(i + "!!");
else
System.out.println(i);
}
for(int i = number;i > 0; i--) { //In reverse order
if(i % 3 == 0)
System.out.println(i + "!!");
else
System.out.println(i);
}
Random random = new Random();
int i = 0;
while(i<15) {
int ran = random.nextInt(500);
if(ran % 3 == 0) {
System.out.println(ran+ "!!");
i++;
}else {
System.out.println(ran);
i++;
}
}
}
}
Recommended Posts