壹外骚年 level
获赞
13
粉丝
0
关注
1
看过 TA
7
重庆邮电大学
2021
Java
IP属地:未知
毛从雷
私信
关注
2020-03-24 11:56
重庆邮电大学 Java
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());            }    }}  大佬看看华为研发工程师编程题里的这道题,太难了! https://www.nowcoder.com/questionTerminal/3245215fffb84b7b81285493eae92ff0
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客企业服务