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());
            }
    }
}
全部评论

相关推荐

不亏是提前批,神仙打架,鼠鼠不配了
站队站对牛:现在92都报工艺岗了
投递韶音科技等公司7个岗位
点赞 评论 收藏
分享
06-20 21:22
已编辑
门头沟学院 Java
纯真的河老师在喝茶:答应了就跑啊,实习随便跑啊,别被pua了,md就是找个廉价劳动力,还平稳过度正式工,到时候跟你说没转正
点赞 评论 收藏
分享
06-10 21:15
门头沟学院 Java
宁阿:好多这种没🧠的公司,他们估计都不知道毕业的人不能给安排实习岗
实习吐槽大会
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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