解题思路:
注意事项:
参考代码:
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int ns[]=new int[2]; ns[0]=sc.nextInt(); ns[1]=sc.nextInt(); ArrayList<Integer>list=new ArrayList<Integer>(); for (int i = 0; i < ns[0]; i++) { int number=sc.nextInt(); if (number%ns[1]!=0) { list.add(number); } } Collections.sort(list); for (int i = 0; i < list.size(); i++) { if (list.get(i)>=65&&list.get(i)<=90) { char ch=(char)(int)list.get(i); System.out.print(ch+" "); } else { System.out.print(list.get(i)+" "); } } } }
0.0分
1 人评分