题解 | #牛牛的二三七整除#
牛牛的二三七整除
https://www.nowcoder.com/practice/b2cf0b791245436f8f0591ae9f4c664f
import java.util.Scanner;
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
int n = in.nextInt();
ArrayList<Integer> a = new ArrayList<Integer>();
if (n % 2 == 0){
a.add(2);
}
if (n % 3 == 0){
a.add(3);
}
if (n % 7 == 0){
a.add(7);
}
if(a.size() == 0){
System.out.print("n");
}
else{
Collections.sort(a);
for(int i : a){
System.out.print(i + " ");
}
}
}
}
}
// int b = in.nextInt();
// int[] a = new int[3];
// if (n % 2 == 0){
// a[0] = 2;
// }
// if (n % 3 == 0){
// a[1] = 3;
// }
// if (n % 7 == 0){
// a[2] = 7;
// }
// for(int i = 0 ; i < a.length; i++){
// System.out.print(a[i] + " ");
// }
