全部评论
判断空字符串输入用while(sc.hasNextLine()) ,而不是sc.hasNext()就过了
有大佬可以帮我看一下代码吗 第二题 public class dechar { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String st=sc.nextLine(); HashSet<Character> hash=new HashSet<>(); int i=0; ArrayList arr=new ArrayList(); while (i<st.length()){ char c=st.charAt(i); if(!hash.contains(c)||c==' &(5528)#39;){ hash.add(c); arr.add(c); i++; }else{ i++; } } for(Object ch:arr){ System.out.print(ch); } } }
有大佬可以帮我看一下代码吗 第一题AC 80%
我不懂为啥第一题输入有问题,后来我用了sys.stdin.readlines()才成功的,耽误了好长时间
可以看看这个帖子:https://www.nowcoder.com/discuss/511789
我第一题输入没整好,就对了第二题
cpp?
相关推荐
点赞 评论 收藏
分享
06-18 22:40
吉林大学 Java 点赞 评论 收藏
分享
点赞 评论 收藏
分享