返回题解分享
讨论 / 题解分享/ 帖子详情

卡片(结果填空) - 题解

public static void main(String[] args) throws IOException {
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < 10; i++) {
            map.put(i + "", 2021);
        }
        int num = 1;
        while(true) {
           String s = num + "";
           String[] s1 = s.split("");
            for (String s2 : s1) {
                if (map.get(s2) == 0) {
                    System.out.println(num - 1);
                    return;
                }else {
                    map.put(s2, map.get(s2) - 1);
                }
            }
            num += 1;
        }
    }
0 回复 0 转发 0 喜欢 6 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!