题解 | #整型数组合并#

整型数组合并

http://www.nowcoder.com/practice/c4f11ea2c886429faf91decfaf6a310b


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Set<Integer> set = new TreeSet<>();
            int n = sc.nextInt();
            for (int i = 0; i < n; i++) {
                set.add(sc.nextInt());
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                set.add(sc.nextInt());
            }
            ArrayList<Integer> list = new ArrayList<>(set);
            for (int i = 0; i < list.size(); i++) {
                if(i == list.size()-1){
                    System.out.println(list.get(i));
                }else{
                    System.out.print(list.get(i));
                }
            }
        }
    }
}
全部评论

相关推荐

07-11 11:15
中南大学 Java
好可爱的hr姐姐哈哈哈哈
黑皮白袜臭脚体育生:兄弟们貂蝉在一起,吕布开了
点赞 评论 收藏
分享
06-07 12:20
新余学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务