标签:algo-50 数组查找及替换 算法 蓝桥杯 java
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); int b = scanner.nextInt(); List<Integer> nums = new ArrayList<>(); for (int i = 0; i < n; i++) { int temp = scanner.nextInt(); if (temp % b != 0) { nums.add(temp); } } Collections.sort(nums); for (int i = 0; i < nums.size(); i++) { if (nums.get(i) >= 'A' && nums.get(i) <= 'Z') { int temp = nums.get(i); char ch = (char) temp; System.out.print(ch); } else { System.out.print(nums.get(i)); } System.out.print(i == nums.size() - 1 ? "\r\n" : " "); } } } }
[ALGO-50] 数组查找及替换,布布扣,bubuko.com
标签:algo-50 数组查找及替换 算法 蓝桥杯 java
原文地址:http://blog.csdn.net/u011506951/article/details/27231479