wc,这个题目有毒
附上我的正确的代码,
import java.util.*;
public class Main{
    public static void main(String[] args){
     Scanner sc = new Scanner(System.in);TreeSet<Integer> ts = new TreeSet<>();
        while (sc.hasNextInt()) {
            if(ts.size()>0)
                ts.clear();
            int length = sc.nextInt();
            for(int i=0;i<length;i++)
                ts.add(sc.nextInt());
            Iterator it = ts.iterator();
            while(it.hasNext()){
                System.out.println(it.next());
            }
       }
    }
}
和按照样例来的代码,按理说下面这个事对的啥,但是就是不对,。。。
import java.util.*;
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);TreeSet<Integer> ts = new TreeSet<>();
        while (sc.hasNextInt()) {int length = sc.nextInt();
            for(int i=0;i<length;i++)
                ts.add(sc.nextInt());
       }Iterator it = ts.iterator(); while(it.hasNext()){
                System.out.println(it.next());
            }
    }
}
全部评论

相关推荐

07-17 11:56
门头沟学院 Java
感谢东子的收留
熬夜脱发码农:无敌了,这是我看到第二个京东的提前批大佬了我还在畏畏缩缩准备八股算法
点赞 评论 收藏
分享
05-26 10:24
门头沟学院 Java
qq乃乃好喝到咩噗茶:其实是对的,线上面试容易被人当野怪刷了
找工作时遇到的神仙HR
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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